3

My program runs in background. I use linux top command, it shows 16g memory. But when I want to use go pprof -inuse_space to check the point, I gives only 200M. Where do the other memory go?

trincot
  • 317,000
  • 35
  • 244
  • 286
darjun
  • 63
  • 1
  • 2
  • 3
    "Memory usage" is a _really_ complicated issue on modern systems. In short: all is fine, there is nothing to worry here. These are two different numbers and they are not related but all is fine. – Volker Jan 04 '19 at 09:56
  • Which column in top? As Volker noted memory usage is complicated, as evidenced by the *three columns of memory usage per process* that top shows you. I'm guessing you looked at `VIRT` (which is huge for pretty much every process ever) and panicked. Look at `RES`, which is a more accurate depiction of process memory usage. – Adrian Jan 04 '19 at 16:26
  • New data is VIRT 42g RES 0.024t。When I use go tool pprof -inuse_space localhost:2000/debug/pprof/heap,it shows it only use 156.75MB memory. I just don't know where the memory sits. – darjun Jan 07 '19 at 01:40

1 Answers1

-1

Generally, the memory used in os(shown by top VIRT) is larger than pprof. One reason is gc will happen when heap size > ($GOGC% + 1) * (reachable nodes size): https://blog.golang.org/go15gc. By default, $GOGC is 100, that means the memory size will be twice of the heap size shown by pprof. But you seem not to be in this case.