-2

I create API that just return string("OK").

enter image description here


And I test it with following configuration. enter image description here


I monitor it with visualVM, and notice that heap usage increase continuously. Eventually jvm perform gc. enter image description here



Question.

  1. why heap usage increase continuously?
eewwq asd
  • 45
  • 1
  • 8
  • 3
    The heap is increasing continuously, because there are allocations, up until the garbage collector runs and reclaims the memory. That’s the normal pattern of garbage collected heaps. Even if your application does not allocate memory on its own, you are looking at the runtime with a tool, the runtime has to communicate with (JMX over RMI), which will create temporary objects. So there still are allocations, even when the application is inactive. – Holger Nov 02 '21 at 08:06

2 Answers2

1

Hello,I guess there is other classes in SpringMVC is created。such as threadlocal

Charles
  • 21
  • 1
1

Better than guessing you can actually use jvisualvm to help you find what objects are there in heap by memory sampling. You can see the number of instances of objects and total size in the profiling section as shown in below screenshot. You can take snapshots while your load test runs and you can then later analyze them. You can even take a heap dump and analyze that with tools like Eclipse Memory Analyzer

enter image description here

Shailendra
  • 8,874
  • 2
  • 28
  • 37