As you've already determined, the memory is all allocated and kept into 'natPool', which is a sync.Pool. from the documentation:
Any item stored in the Pool may be removed automatically at any time without notification. If your pool memory usage grows all the time, this is an indication that you may not using it correctly: you're not fetching preallocated objects via natPool.Get(), but probably allocating a new one each time and putting it in the pool, hence the growth. The other option is that you are calling the pool's Get method, but sync.Pool will keep growing until it reaches some arbitrary limit and it just hasn't done it yet. Both of these require that you show us more code for better diagnosis :) On Sat, Oct 15, 2016 at 7:46 AM, Raffaele Di Fazio <difazio.raffa...@gmail.com> wrote: > Hi, > I have a web application that over time uses more and more memory. This is > the output of pprof of the heap: > > go tool pprof -alloc_space lushan-server > https://localhost:8083/debug/pprof/heap > Fetching profile from https://localhost:8083/debug/pprof/heap > Saved profile in > /Users/rdifazio/pprof/pprof.lushan-server.localhost:8083.alloc_objects.alloc_space.022.pb.gz > Entering interactive mode (type "help" for commands) > (pprof) top > 43.06MB of 67.07MB total (64.20%) > Dropped 4 nodes (cum <= 0.34MB) > Showing top 10 nodes out of 188 (cum >= 1.50MB) > flat flat% sum% cum cum% > 26MB 38.76% 38.76% 26MB 38.76% math/big.putNat > 3MB 4.48% 43.24% 3.50MB 5.22% > encoding/json.(*decodeState).objectInterface > 2.50MB 3.73% 46.97% 2.50MB 3.73% crypto/tls.(*Conn).write > 2MB 2.98% 49.96% 2MB 2.98% crypto/tls.(*block).reserve > 2MB 2.98% 52.94% 10.50MB 15.66% encoding/json.Unmarshal > 1.55MB 2.31% 55.25% 1.55MB 2.31% regexp.(*bitState).reset > 1.50MB 2.24% 57.49% 9.50MB 14.17% > github.com/go-openapi/spec.(*Schema).UnmarshalJSON > 1.50MB 2.24% 59.72% 27.50MB 41.00% math/big.nat.divLarge > 1.50MB 2.24% 61.96% 5.50MB 8.20% math/big.nat.expNN > 1.50MB 2.24% 64.20% 1.50MB 2.24% crypto/sha512.New384 > (pprof) > > > ROUTINE ======================== math/big.putNat in > /usr/local/Cellar/go/1.7.1/libexec/src/math/big/nat.go > 26MB 26MB (flat, cum) 38.76% of Total > . . 550: } > . . 551: return z.make(n) > . . 552:} > . . 553: > . . 554:func putNat(x nat) { > 26MB 26MB 555: natPool.Put(x) > . . 556:} > . . 557: > . . 558:var natPool sync.Pool > . . 559: > . . 560:// q = (uIn-r)/v, with 0 <= r < y > > > > The memory allocated in math/big.putNat seems to increase over time, > generating a very high usage of memory for a web applications that is > executing very few requests per second. I wonder why and how I can better > analyze this issue. Please notice that this happens only when serving HTTPS. > > I'm currently using go 1.7 and the app itself uses the gin web framework. > > Thanks in advance! > > Raffaele > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.