Why a sawtooth shaped graph?

后端 未结 4 1119
鱼传尺愫
鱼传尺愫 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 08:17

    Actually jVisualVM causing additional object allocation. jVisualVM and jconsole are using Java Management Extensions. Attaching to running application and requesting JVM metrics causing that additional objects are being created. You can verify this by adding to your program call to

    Runtime.getRuntime().freeMemory() 
    

    which reports free memory in JVM heap. It will show [almost] no memory change by running your code, but as soon as you connect jVisualVM to your program you'll see memory usage increase.

提交回复
热议问题