일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- 줄바꿈 문자
- Eclipse
- ssh
- 네트워크
- VirtualBox
- web.xml
- vscode
- bash
- Source
- IntelliJ
- GIT
- Windows
- lsof
- netsh
- profile
- Windows 10
- 단축키
- find
- xargs
- tomcat
- context
- resource
- plugin
- Quartz
- grep
- JavaScript
- maVen
- port
- import
- Mac
- Today
- Total
develog
memory 본문
public class TestMain {
public static void main(String[] args) {
System.out.println("START");
System.out.println("----------------------------------------------");
/*
totalMemory
Returns the total amount of memory in the Java virtual machine.
maxMemory
Returns the maximum amount of memory that the Java virtual machine will attempt to use.
freeMemory
Returns the amount of free memory in the Java Virtual Machine.
*/
Runtime r = Runtime.getRuntime();
printSize("totalMemory", r.totalMemory());
printSize("maxMemory", r.maxMemory());
printSize("freeMemory", r.freeMemory());
System.out.println("----------------------------------------------");
System.out.println("END");
}
private static void printSize(String memType, long bytes) {
String TAB = "\t";
System.out.print(memType);
System.out.print(TAB + bytes);
System.out.print(TAB + getKB(bytes));
System.out.print(TAB + getMB(bytes));
System.out.println();
}
private static String getKB(long bytes) {
String r = (bytes / 1024) + " KB";
return r;
}
private static String getMB(long bytes) {
String r = (bytes / 1024 / 1024) + " MB";
return r;
}
}
// output
START ---------------------------------------------- totalMemory 10682368 10432 KB 10 MB maxMemory 18677760 18240 KB 17 MB freeMemory 10406024 10162 KB 9 MB ---------------------------------------------- END |
'Dev > Java' 카테고리의 다른 글
[Java] http 인증 접속 (0) | 2014.09.18 |
---|---|
[Java] System.getProperties(), System.getProperty() (0) | 2014.09.15 |
eclipse.ini (0) | 2014.09.10 |
[Java] 익명 PL/SQL 블럭 실행 (0) | 2014.08.29 |
[Spring] dbcp 설정 (0) | 2014.08.08 |