📄 main.java
字号:
public class Main {
private static BigString[] bsarray = new BigString[1000];
public static void main(String[] args) {
System.out.println("共享时:");
testAllocation(true);
System.out.println("不共享时:");
testAllocation(false);
}
public static void testAllocation(boolean shared) {
for (int i = 0; i < bsarray.length; i++) {
bsarray[i] = new BigString("1212123", shared);
}
showMemory();
}
public static void showMemory() {
Runtime.getRuntime().gc();
long used = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
System.out.println("内存使用量= " + used);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -