heapaudit 是 foursquare 的一个 jvm 内存分析工具,网上有人运行得很好,但为何我会运行失败呢?
import java.util.HashMap; import com.foursquare.heapaudit.*; public class Test { public static void main(String[] args) { final HeapQuantile r = new HeapQuantile(); HeapRecorder.register(r, HeapRecorder.Threading.Local); try { int[] array1D = new int[9]; int[][][] array3D = new int[8][29][5]; HashMap map = new HashMap(); for (int i = 0; i < 25; ++i) { map.put(i, i); } } finally { HeapRecorder.unregister(r, HeapRecorder.Threading.Local); for (final HeapQuantile.Stats s : r.tally(HeapRecorder.Threading.Local, true)) { System.out.println(s); } } } }
运行:
$ java -Xbootclasspath/a:/opt/java/lib/tools.jar -javaagent:heapaudit.jar Test Exception in thread "main" FATAL ERROR in native method: processing of -javaagent failed Aborted
我怀疑是不是因为我用的是 java 1.7
人生最曼妙的风景,竟是内心的淡定与从容!