码迷,mamicode.com
首页 > 编程语言 > 详细

JAVA 大数据内存耗用测试

时间:2016-01-09 18:19:26      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:

JAVA 大数据内存耗用测试
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;


public class MemoryTest {
public static void main(String[] args) throws InterruptedException {
int row = 50_000;
int column = 20;
String[] data = new String[row * column];
for (int i = 0; i < data.length; i++) {
data[i] = "columnName" + (i % column);
}

while (true) {
int i = (int) (Math.random() % (row * column));
if (data[i] == data[(i + column) % (row * column)]) {
System.out.println("the seme object");
}

System.gc();

MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
long used = memoryMXBean.getHeapMemoryUsage().getUsed();
System.out.println("used:" + used / 1024d /1024d);
Thread.sleep(10_000);
}
}
}

JAVA 大数据内存耗用测试

标签:

原文地址:http://www.cnblogs.com/zfswff/p/5116705.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!