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

NSMgr leaks memory somewhere (probably in grpcfd) #375

Closed
Bolodya1997 opened this issue Sep 23, 2021 · 5 comments
Closed

NSMgr leaks memory somewhere (probably in grpcfd) #375

Bolodya1997 opened this issue Sep 23, 2021 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@Bolodya1997
Copy link

Current Behavior

NSMgr leaks memory somewhere (probably in grpcfd) after long time working.
image
nsmgr-8g8qn.pb.gz

Steps to Reproduce

  1. Patch NSMgr with the following lines in main.go:
import _ "net/http/pprof"
go func() {
	_ = http.ListenAndServe("127.0.0.1:8080", nil)
}()
  1. Run some example for a long time (12+ hours).
  2. Collect heap profile with go tools pprof.
@Bolodya1997 Bolodya1997 added the bug Something isn't working label Sep 23, 2021
@Bolodya1997 Bolodya1997 self-assigned this Sep 24, 2021
@Bolodya1997
Copy link
Author

Bolodya1997 commented Sep 27, 2021

Tried to run NSM without any grpcfd either in networkservice or in registry chains. Almost no leaks for 3 days running setup.
nsmgr-b6r9b.pb.gz
So it keeps looking like the cause of the leaks is somewhere in grpcfd.

In inuse_objects sample I can see registry server.Find leaks in spanlogger, there is already an issue for this - networkservicemesh/sdk#1085.

In inuse_space sample there is a possible leak in gRPC transport.NewBufWriter (~1Mb), but there are only 17 objects, so it can be a normal behavior, needs to be further monitored.

@edwarnicke
Copy link
Member

edwarnicke commented Sep 27, 2021

@Bolodya1997 grpcfd should be cleaning up after open file descriptors on connection close

https://github.com/edwarnicke/grpcfd/blob/aa90c1562fb36d3f274db049354d6a1e76fd325a/connwrap.go#L102-L122

@edwarnicke
Copy link
Member

@Bolodya1997 in recvfd we are caching files and closing them when the client Connection closes: https://github.com/networkservicemesh/sdk/blob/204761283a51aa10efcf3d994c36c74b50355e26/pkg/networkservice/common/mechanisms/recvfd/client.go#L88-L94

But we appear to be neglecting to do so on the server side:

https://github.com/networkservicemesh/sdk/blob/204761283a51aa10efcf3d994c36c74b50355e26/pkg/networkservice/common/mechanisms/recvfd/server.go#L80-L109

In principle on the Server side once https://github.com/networkservicemesh/sdk/blob/204761283a51aa10efcf3d994c36c74b50355e26/pkg/networkservice/common/mechanisms/recvfd/server.go#L92 happens the files should eventually get closed due to finalization by the garbage collector... but explicit is better than implicit.

@Bolodya1997
Copy link
Author

@edwarnicke
There was an issue with finalizer, fixed it - edwarnicke/grpcfd#19.

@edwarnicke
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants