java问题
[TOC]
学习过程中遇到的一些技术问题。
String interning
String interning keeps every String only once in memory.
https://en.wikipedia.org/wiki/String_interning
关于java程序种的内存
Total designated memory, this will equal the configured -Xmx value: Runtime.getRuntime().maxMemory();
Current allocated free memory, is the current allocated space ready for new objects. Caution this is not the total free available memory: Runtime.getRuntime().freeMemory();
Total allocated memory, is the total allocated space reserved for the java process: Runtime.getRuntime().totalMemory();
Used memory, has to be calculated:
usedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
Total free memory, has to be calculated: freeMemory = Runtime.getRuntime().maxMemory() - usedMemory;
如图所示:
参考链接:
https://stackoverflow.com/questions/3571203/what-are-runtime-getruntime-totalmemory-and-freememory