This article describes how to view memory allocation stacktrace in Java VisualVM: http://rejeev.blogspot.de/2009/04/analyzing-memory-leak-in-java.html
In short, define a custom preset in the Java VisualVM options and check the "record allocations stack traces" checkbox in the memory settings tab.
Now, when I select that custom preset and start memory profiling, I still cannot view the memory allocation stacktrace. There is no right-click-on-item action "Take snapshot and show allocation stack traces" as described in the article, nor a anything like that. I am using VisualVM 1.7.
How can I view these allocation stack traces?
Attach VisualVM to your application. Perform the operation that causes the sluggish performance. Inspect the 'Monitor' and the 'memory pools' tab. If you see that your memory increases in the 'Monitor' tab, try pressing 'Perform GC' (garbage collection) and see if that decreases memory usage.
Under the Local node in the Applications window, right-click the application node and choose Open to open the application tab. Click the Profiler tab in the application tab. Click Memory or CPU in the Profiler tab. When you choose a profiling task, VisualVM displays the profiling data in the Profiler tab.
To find the location of your Java VisualVM userdir, choose Help > About from the main menu and click Details in the About Java VisualVM window.
The Profiler tab of an application enables you to start and stop the profiling session of a local application. Profiling results are displayed in the Profiler tab. You can use the toolbar to refresh the profiling results, invoke garbage collection and save the profiling data.
If you can't see this option, go to Profiler -> activate "Settings" check box and activate "Record allocation stack traces" while the profiler is not active.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With