panjf2000 / gnet

🚀 gnet is a high-performance, lightweight, non-blocking, event-driven networking framework written in pure Go.

Home Page:https://gnet.host

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: memory leaks in `conn.release`

panjf2000 opened this issue · comments

Actions I've taken before I'm here

  • I've thoroughly read the documentations on this issue but still have no clue.
  • I've searched the Github Issues but didn't find any duplicate issues that have been resolved.
  • I've searched the internet for this issue but didn't find anything helpful.

What happened?

memory leaks of localAddr and remoteAddr:

gnet/connection_unix.go

Lines 86 to 96 in 6d01da7

func (c *conn) release() {
c.ctx = nil
c.localAddr = nil
c.remoteAddr = nil
c.buffer = nil
if addr, ok := c.localAddr.(*net.TCPAddr); ok && c.localAddr != c.loop.ln.addr && len(addr.Zone) > 0 {
bsPool.Put(bs.StringToBytes(addr.Zone))
}
if addr, ok := c.remoteAddr.(*net.TCPAddr); ok && len(addr.Zone) > 0 {
bsPool.Put(bs.StringToBytes(addr.Zone))
}

This issue was introduced by #460

Major version of gnet

v2

Specific version of gnet

v2.3.0-rc.1

Operating system

Linux

OS version

any

Go version

any

Relevant log output

None

Code snippets (optional)

No response

How to Reproduce

Steps to reproduce the behavior:

  1. Go to '....'
  2. Click on '....'
  3. Do '....'
  4. See '....'

Does this issue reproduce with the latest release?

It can reproduce with the latest release