In Eclipse, when debugging, is there an easy way to see a variable's total memory size?
From the Debug view, when looking at the Variables tab, is there a way to easily see how much of the heap a gi开发者_如何学Goven variable is consuming? (Something akin to Java's Heap Analysis Tool)
I think this will help:
Memory Analyzer (MAT)
The Eclipse Memory Analyzer is a fast and feature-rich Java heap analyzer that helps you find memory leaks and reduce memory consumption.
Use the Memory Analyzer to analyze productive heap dumps with hundreds of millions of objects, quickly calculate the retained sizes of objects, see who is preventing the Garbage Collector from collecting objects, run a report to automatically extract leak suspects.
A half-measure would be to watch for changes in the total RunTime's used ram with something like:
Runtime rt = Runtime.getRuntime();
long currInUse = rt.totalMemory() - rt.freeMemory();
精彩评论