VisualVM: perfect heap memory usage diagram

I track my Java application (written in JDK 1.7 ) with VisualVM . The following is a graph showing heap memory usage for the duration of this application.

enter image description here

Looking at this graph, you will see that it has a lot of spikes. These spikes indicate the creation of objects by the application. When an application runs with them, it destroys them using gc (implicitly called in this case).

Also, here is a screenshot of the memory profiler when the application is still running

enter image description here

For me, the upper and lower nature of the graph indicates the efficient use of Java objects. Is this conclusion correct?

What is the ideal nature of the heap usage schedule to strive for?

Are there other ways to improve heap memory usage in an application?

+6
source share
2 answers

For me, the upper and lower nature of the graph indicates the efficient use of Java objects. Is this conclusion correct?

I would say that this is an efficient use of the garbage collector. I would suggest that creating a smaller object might be more efficient.

What is the ideal heap usage schedule to strive for?

It depends on your application. I tend to strive for one that is almost completely flat.

Are there other ways to improve heap memory usage in an application?

Cargo

  • create less trash. Use your memory profiler to find out where the garbage is created.
  • make the heap larger as it is not GC so often.
  • move stored data from the heap (you don't seem to have much)

In your case, the best option would be to reduce the amount of garbage that you produce.

+3
source

As long as the heap size is almost the same over time, you're fine. The heap used must go up and down due to the nature of the pause in the gc world in the Sun JVM. It looks like a lot of short-lived objects are being created in your application, this may be inefficient, but sometimes you need to create them. This is a Java lifestyle: D

+1
source

Source: https://habr.com/ru/post/976509/


All Articles