首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

JAVA调优之工具:j地图+mat

2012-10-30 
JAVA调优之工具:jmap+mat用途:用来查找内存泄露 介绍????????? Jmap:jdk自带,主要用来查看JVM各个代的内存

JAVA调优之工具:jmap+mat

用途:用来查找内存泄露
介绍
?
???????? Jmap:jdk自带,主要用来查看JVM各个代的内存情况或内存占用状况, 支持导出整个JVM内存信息
????????? MAT :Eclipse 内存分析工具:http://www.eclipse.org/mat
使用
1、dump出内存信息:jmap -dump:format=b,file=dump.bin pid
2、eclipse 安装好mat插件: http://download.eclipse.org/mat/1.0/update-site/
3、eclipse直接打开dump的文件:dump.bin(注意:eclipse 内存设置大一点)
4、mat工具的具体使用网上比较多,还是比较好使用。分析后的文件可以生成html格式的,方便离线使用

?

试验代码

public class OutOfMemory {    private String str;    public OutOfMemory(String str) {        this.str = str;    }    public static void main(String[] args) throws InterruptedException {        HashMap<Integer, OutOfMemory> map = new HashMap<Integer, OutOfMemory>();        String s = "O";        for (Integer i = 0; i < 100; i++) {            s += s;            OutOfMemory o = new OutOfMemory(s);            map.put(i, o);            Thread.sleep(2000);            System.out.println(i);        }    }}

?

运行:java –Xmx128m –Xms128m OutOfMemory






?

热点排行