0

I have a go microservice for which the resident memory consumption is constantly increasing with number of requests.

I used pprof to determine whether i have any of following scenarios:

  • increasing goroutines (remains consistent and the number drops down as load is decreased)
  • heap size (heap size (inuse_space and inuse_objects)) remains consistent throughout the time

I went to the pprof interactive page http://localhost:6060/debug/pprof/ and saw that the allocs and heap are increasing.

Timestamp 1

Types of profiles available:
Count   Profile
46  allocs
0   block
0   cmdline
109 goroutine
46  heap
0   mutex
0   profile
15  threadcreate
0   trace

Timestamp 2

Types of profiles available:
Count   Profile
62  allocs
0   block
0   cmdline
109 goroutine
62  heap
0   mutex
0   profile
16  threadcreate
0   trace

Below are the heap info at Timestamp 1 & 2 https://file.io/YdSLRVGIBa7N

How can i determine why this memory consumption is increasing? Could this also be an issue with GC (memory not being released to OS)? I am on go version 1.20.2.

Manish Gupta
  • 4,438
  • 18
  • 57
  • 104
  • 1
    Memory use increases as it's needed by the program, and the GC attempts to balance allocation and reuse. You can't really get memory leaks with a precise GC, so the first thing to confirm is that you are not leaking goroutines. If you feel the need to adjust how the GC operates, it's best to start by reading up about how garbage collections works, this might help: https://tip.golang.org/doc/gc-guide. – JimB Aug 04 '23 at 15:43

0 Answers0