How to track any object instantiation on my JVM with Runtime.freeMemory() and GC
问题 I am using the default GC with 1.6.0_27-b07 (Sun's JRE) and because of this I am not able to detect an increase in memory with Runtime.getRuntime().freeMemory(). Can anyone shed a light on how to accomplish this? Do I have to use a different GC? Which one? The simple program below prints 0 for the memory allocated. :( :( :( import java.util.HashSet; import java.util.Set; public class MemoryUtils { private static Set<String> set = new HashSet<String>(); public static void main(String[] args) {