java - heapaudit 运行失败

 手机用户2502871993 发布于 2022-11-06 16:17

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 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

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有