首页 > 其他 > 详细

Map存储容量及内存占用测试

时间:2017-07-25 14:12:04      阅读:347      评论:0      收藏:0      [点我收藏+]

Integer a = 1;
long start = 0;
long end = 0;
// 先垃圾回收
System.gc();
start = Runtime.getRuntime().freeMemory();
HashMap map = new HashMap();
for (int i = 0; i < 1000000; i++) {
map.put(i, a);
}
// 快要计算的时,再清理一次
System.gc();
end = Runtime.getRuntime().freeMemory();
System.out.println("一个HashMap对象占内存:" + (end - start));

Map存储容量及内存占用测试

原文:http://www.cnblogs.com/fan-yuan/p/7233671.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!