diff --git a/pkg/iplibrary/default_ip_library.go b/pkg/iplibrary/default_ip_library.go index 8052abd..11741cc 100644 --- a/pkg/iplibrary/default_ip_library.go +++ b/pkg/iplibrary/default_ip_library.go @@ -115,3 +115,9 @@ func (this *IPLibrary) LookupIP(ip string) *QueryResult { } return this.Lookup(net.ParseIP(ip)) } + +func (this *IPLibrary) Destroy() { + if this.reader != nil { + this.reader.Destroy() + } +} diff --git a/pkg/iplibrary/reader.go b/pkg/iplibrary/reader.go index 0b0dab7..49cb4b1 100644 --- a/pkg/iplibrary/reader.go +++ b/pkg/iplibrary/reader.go @@ -170,6 +170,13 @@ func (this *Reader) IPv6Items() []*ipv6Item { return this.ipV6Items } +func (this *Reader) Destroy() { + this.meta = nil + this.regionMap = nil + this.ipV4Items = nil + this.ipV6Items = nil +} + // 分析数据 func (this *Reader) parse(data []byte) (left []byte, err error) { if len(data) == 0 {