1

I have a server written in Go which does not release the consumed memory. I started the program with the GODEBUG=gctrace=1 option and I get the following output:

scvg44: inuse: 1, idle: 423, sys: 425, released: 423, consumed: 1 (MB)
scvg45: inuse: 1, idle: 423, sys: 425, released: 423, consumed: 1 (MB)
...
scvg49: inuse: 1, idle: 423, sys: 425, released: 423, consumed: 1 (MB)
scvg50: inuse: 1, idle: 423, sys: 425, released: 423, consumed: 1 (MB)

So while the output says that 423 MB are released to the OS that seems not to be the case. The program has 423 MB idle memory for hours. Why does the program not release the memory?

Christian
  • 21
  • 2
  • what version of Go are you running 1.4 or 1.5? – RickyA Nov 23 '15 at 15:51
  • latest version 1.5.1 – Christian Nov 23 '15 at 15:52
  • 1
    Take a look at [this](http://stackoverflow.com/questions/24863164/how-to-analyse-golang-memory) answer, that explains that no memory is released to os once it has been used by the program. – RickyA Nov 23 '15 at 15:53
  • What OS are you using, and how are you measuring actual memory usage? `HeapIdle` and `HeapReleased` may refer to the same memory, and new allocations may take away from both of those stats. (Also the OS isn't obligated to "free" the memory from the process, but you need to measure that from the OS) – JimB Nov 23 '15 at 16:39
  • I found this question & answer very useful on how the garbage collector is operating and there is a delay before the memory is handed back to the OS: http://stackoverflow.com/questions/24376817/go-1-3-garbage-collector-not-releasing-server-memory-back-to-system – miltonb Nov 23 '15 at 19:56
  • Maybe this post can help you. http://stackoverflow.com/questions/24863164/how-to-analyse-golang-memory?answertab=votes#tab-top – kongxx Jan 12 '17 at 04:46

0 Answers0