Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: failed connect/accept leaks memory associated to runtime.PollDesc #5219

Closed
dvyukov opened this issue Apr 5, 2013 · 5 comments

Comments

Projects
None yet
4 participants
@dvyukov
Copy link
Member

commented Apr 5, 2013

Based on code examination by Mikio:
https://golang.org/cl/8318044/
@mikioh

This comment has been minimized.

Copy link
Contributor

commented Apr 6, 2013

Comment 1:

I guess it wouldn't be a problem in real use cases at server side but
not at intermediaries, issue #2449 might come back again probably.
@mikioh

This comment has been minimized.

Copy link
Contributor

commented Apr 6, 2013

Comment 2:

I guess it wouldn't be a problem in real use cases at server side but
not at intermediaries,  issue #2349  might come back again probably.
@mikioh

This comment has been minimized.

Copy link
Contributor

commented Apr 6, 2013

Comment 3:

The real issue would be unnecessary memory consumption.
E.g., one runtime.PollDesc (lt 200 bytes) per Page (ge 4096 bytes) acquired by
runtime.SysAlloc.
@mikioh

This comment has been minimized.

Copy link
Contributor

commented Apr 6, 2013

Comment 4:

The problem would be unnecessary memory consumption because
runtime.pollcache keeps consuming memory for runtime.PollDesc
when it requires. We should feed descriptors to the pollcache either
clean ones from the kernel or the spent ones by calling pollClose.
src/pkg/runtime/netpoll.goc:
static PollDesc*
allocPollDesc(void)
{
        PollDesc *pd;
        uint32 i, n;
        runtime·lock(&pollcache);
        if(pollcache.first == nil) {
                n = PageSize/sizeof(*pd);
                if(n == 0)
                        n = 1;
                // Must be in non-GC memory because can be referenced
                // only from epoll/kqueue internals.
                pd = runtime·SysAlloc(n*sizeof(*pd));
                for(i = 0; i < n; i++) {
                        pd[i].link = pollcache.first;
                        pollcache.first = &pd[i];
                }
        }
        pd = pollcache.first;
        pollcache.first = pd->link;
        runtime·unlock(&pollcache);
        return pd;
}
@mikioh

This comment has been minimized.

Copy link
Contributor

commented Apr 9, 2013

Comment 5:

This issue was closed by revision e13341e.

Status changed to Fixed.

@dvyukov dvyukov added fixed labels Apr 9, 2013

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015

@rsc rsc removed the go1.1 label Apr 14, 2015

@golang golang locked and limited conversation to collaborators Jun 24, 2016

This issue was closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.