Java – why is heap memory usage and the number of loaded classes increasing?
I am using JVM Explorer – link to JVM explorer to analyze my spring application I have the following questions
>Why does' use heap memory 'keep increasing even after the application has started and has not received any requests? (Figure 1) > why is' second hand heap memory 'increasing even after garbage collection and before any requests are received? (image 2) > why is the number of loaded classes increasing after garbage collection by sending some requests to the application? Shouldn't the application use the previous class? Why does it just increase almost everything (heap, number of loaded classes)? (image 3)
After application – enlarger image
After clicking the "run garbage collector" button. –@ L_ 404_ 2@
After completing the garbage collector – enlarger image, send some requests to the application
Solution
Something in the JVM is creating objects You need a memory analyzer to see what this does It may be part of swing, or yoru applications, or other libraries
BTW most analysis tools use JMX to deal with a large amount of garbage For example, when I run flightrecorder or visualvm on some of my applications, it shows that JMX monitoring is creating most of the garbage
No matter what the object is created, it is still being created
Classes are lazily loaded You don't need some lessons before you do something
Yes, but that doesn't mean it doesn't need more courses
Your application is doing more work
If you don't know what the application is doing, I recommend using a memory analyzer such as visual VM or flight recorder I use yourkit to solve these problems
Note: adjusting Java programs requires hard work so that they do not generate garbage. I would say that most libraries only try to reduce garbage when they cause known performance problems