查看java進程運行狀況
jps -lvm
查看java默認堆大小
java -XX:+PrintFlagsFinal | grep MaxHeapSize
eclipse調試設置vm參數
在項目上右鍵,依次點擊“Debug As ”-> “Debug Configurations ”,在Arguments 參數中的“VM arguments: ”中填入如下值即可。
查看vm參數
public class TestMemory {
/**
* @param args
*/
public static void main(String[] args) {
System. out .println( " 內存信息 :" + toMemoryInfo());
}
/**
* 獲取當前 jvm 的內存信息
*
* @return
*/
public static String toMemoryInfo() {
Runtime currRuntime = Runtime.getRuntime ();
int nFreeMemory = ( int ) (currRuntime.freeMemory() / 1024 / 1024);
int nTotalMemory = ( int ) (currRuntime.totalMemory() / 1024 / 1024);
return nFreeMemory + "M/" + nTotalMemory +"M(free/total)" ;
}
}
posted on 2015-11-28 08:51
水 閱讀(315)
評論(0) 編輯 收藏 引用 所屬分類:
Java