0
So people, I’d like to know if you have any method or even way to get the amount of Garbage generated at the current moment of the code. If you do not know but if you know any DOC that I can study to find a way, thank you.
0
So people, I’d like to know if you have any method or even way to get the amount of Garbage generated at the current moment of the code. If you do not know but if you know any DOC that I can study to find a way, thank you.
0
I’m not sure you’re gonna get exactly what you want, but maybe in one of the classes MemoryMXBean
or MemoryPoolMXBean
.
Instances of these classes can be obtained with the help of the class ManagementFactory
:
MemoryMXBean memory = ManagementFactory.getMemoryMXBean();
Browser other questions tagged java garbage-collector intellij-idea
You are not signed in. Login or sign up in order to post.
Do you want to know this at runtime? If you cannot use a static code analysis tool. For example Sonarqube
– igventurelli
Yes, at runtime...
– A. Sousa
I think that only with some profiler... Search for Visualvm it comes along with JDK
– igventurelli
I use Jprofiler, but for this case I want to put the quantity in a variable :/
– A. Sousa
Oh right.. I think there’s no way... If you don’t really save the profiler data in some file that the application can read :P
– igventurelli
Maybe it will help? http://docs.oracle.com/javase/6/docs/api/java/lang/management/GarbageCollectorMXBean.html; https://stackoverflow.com/q/466878/4438007
– Jefferson Quesado