Why a sawtooth shaped graph?

后端 未结 4 1105
鱼传尺愫
鱼传尺愫 2020-12-03 07:20

When I run the below mentioned code using NetBeans, the allocated heap size graph resembles a sawtooth shape. I am attaching the screen capture from JVisualVM which shows th

4条回答
  •  有刺的猬
    2020-12-03 07:55

    Any process allocating objects at regular rate will result in a steady increase in heap memory consumption, followed by instantaneous drops when the garbage collector collects the no longer used objects, resulting in that sawtooth shape.

    In case you wonder why your java process keeps allocation memory while writing to System.out, keep in mind that other threads (for instance the one feeding the current memory statistics to JVisualVM) may be the ones allocating the memory.

提交回复
热议问题