首页 > heapaudit 运行失败

heapaudit 运行失败

heapaudit 是 foursquare 的一个 jvm 内存分析工具,网上有人运行得很好,但为何我会运行失败呢?

  1. attach 模式可以运行,但退出后没有输出,也没有任何报错,原因不明
  2. 运行单元测试 mvn verify ,有 4 个 failure
  3. 于是我打算用需要修改代码的方式。照着例子写了个程序:
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<Integer, Integer> map = new HashMap<Integer, Integer>();
            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

【热门文章】
【热门文章】