ccache icon indicating copy to clipboard operation
ccache copied to clipboard

memory leak

Open hktalent opened this issue 1 year ago • 3 comments

github.com/karlseguin/ccache image

hktalent avatar Jul 29 '22 10:07 hktalent

I don't immediately know. Any context? Was Stop called on the cache? What type of objects are being stored in it? Anything else?

karlseguin avatar Jul 30 '22 03:07 karlseguin

@karlseguin thanks for you

Using multi-instance and multi-threading using nuclei in encapsulation https://github.com/projectdiscovery/nuclei/issues/2357 when, through

  • 1 Export the profile of the heap at time point 1: curl -s http://192.168.10.31:6060/debug/pprof/heap > base.heap
  • 2 Export the heap profile at time point 2: curl -s http://192.168.10.31:6060/debug/pprof/heap > current.heap
  • 3 Compare the difference of the stacks at two time points: go tool pprof --http :8080 --base base.heap current.heap

found when comparing

hktalent avatar Jul 30 '22 03:07 hktalent

Thanks, that helps, but I'm not sure it's a bug.

ccache.New starts a goroutine. To stop it, Stop() needs to be called. If caches are created and fall out of scope without calling Stop() the goroutine will leak.

karlseguin avatar Jul 30 '22 06:07 karlseguin