您的位置:首页 > 大数据

JAVA 大数据内存耗用测试

2016-01-09 16:32 429 查看
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);
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: