1

Is there a JVM option to print out the total memory allocated during a run without running through an instrumented profiler?

I'm certainly not an expert on how the memory allocator within Java works, but surely keeping track of total bytes allocated should be possible with almost no overhead.

I can't run in profiler since this application needs to handle tens of thousands of messages per second (much more at the peak) for many hours; the overhead of a profiler would make it unfeasible.

Thanks

Karim
  • 11
  • 1
  • Why do you think this information could be useful? – Stephen C Oct 06 '13 at 23:46
  • About 12 hours a day, this application needs to run with very low latency. This is information would be useful since it would help me decide if I need to massively reduce memory usage (use object pools, etc ...) to reduce the number of GC's, or whether I can just have a huge heap and avoid GC's altogether during business hours. – Karim Oct 07 '13 at 01:16
  • 1
    Simply knowing how much memory is allocated does NOT answer those questions. I don't think it even helps. You really need to use a memory profiler ... despite your protestations. If necessary, set up a test server and profile that using messages taken from production. – Stephen C Oct 07 '13 at 01:55

1 Answers1

0

AFAIK, there is no such JVM option.

You could enable GC logging and try to infer memory allocation statistics from the space sizes. But that only reports when the GC runs ... not at the application start and end.


I just wonder why there wouldn't be a JVM option for this.

Frankly, because it would not be useful. Knowing how much memory is allocated during a run does not help you understand how to tune your application.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • Thank you ... yeah there a couple of options like that ... basically I think I could set new-gen to something pretty small, and then parse the GC output .. and the answer would be accurate to within the size of new-gen (which is perfectly acceptable in my case). I just wonder why there wouldn't be a JVM option for this. – Karim Oct 07 '13 at 01:20