查看java進程運行狀況
jps -lvm
查看java默認堆大小
java -XX:+PrintFlagsFinal | grep MaxHeapSize
eclipse調(diào)試設(shè)置vm參數(shù)
在項目上右鍵,依次點擊“Debug As ”-> “Debug Configurations ”,在Arguments 參數(shù)中的“VM arguments: ”中填入如下值即可。
查看vm參數(shù)
public class TestMemory {
/**
* @param args
*/
public static void main(String[] args) {
System. out .println( " 內(nèi)存信息 :" + toMemoryInfo());
}
/**
* 獲取當前 jvm 的內(nèi)存信息
*
* @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
水 閱讀(318)
評論(0) 編輯 收藏 引用 所屬分類:
Java