public class TestGC {
/**
* @param args
* @author strong
* 2011-7-18_下午04:35:28
*/
public static void main(String[] args) {
int count =1000000;
long total1 = Runtime.getRuntime().totalMemory();
long starttime1 = System.currentTimeMillis();
for(int i=0;i<count;i++){
String d = "dddddddddddddd";
System.out.println(d);
}
long free1 =Runtime.getRuntime().freeMemory();
long endtime1 = System.currentTimeMillis();
Runtime.getRuntime().gc();//如果放在循环中将需要时间比较长。11ms/9094ms
// System.gc();
long free2 =Runtime.getRuntime().freeMemory();
long endtime2 = System.currentTimeMillis();
System.out.println(count+"次---gc前消耗内存:"+(total1-free1)/1024+"KB");
System.out.println(count+"次---gc消耗内存:"+(total1-free2)/1024+"KB");
System.out.println(count+"次---gc前消耗的时间:"+(endtime1-starttime1)+"ms");
System.out.println(count+"次---gc消耗的时间:"+(endtime2-endtime1)+"ms");
System.out.println(count+"次---消耗的时间:"+(endtime2-starttime1)+"ms");
}
}
100次---gc前消耗内存:317KB
100次---gc消耗内存:134KB
100次---gc前消耗的时间:3ms
100次---gc消耗的时间:12ms
100次---消耗的时间:15ms
100次---gc前消耗内存:317KB
100次---gc消耗内存:134KB
100次---gc前消耗的时间:7ms
100次---gc消耗的时间:11ms
100次---消耗的时间:18ms
1000次---gc前消耗内存:341KB
1000次---gc消耗内存:134KB
1000次---gc前消耗的时间:106ms
1000次---gc消耗的时间:16ms
1000次---消耗的时间:122ms
1000次---gc前消耗内存:341KB
1000次---gc消耗内存:134KB
1000次---gc前消耗的时间:122ms
1000次---gc消耗的时间:10ms
1000次---消耗的时间:132ms
10000次---gc前消耗内存:1453KB
10000次---gc消耗内存:134KB
10000次---gc前消耗的时间:545ms
10000次---gc消耗的时间:12ms
10000次---消耗的时间:557ms
10000次---gc前消耗内存:1463KB
10000次---gc消耗内存:134KB
10000次---gc前消耗的时间:571ms
10000次---gc消耗的时间:30ms
10000次---消耗的时间:601ms
100000次---gc前消耗内存:11251KB
100000次---gc消耗内存:134KB
100000次---gc前消耗的时间:1839ms
100000次---gc消耗的时间:17ms
100000次---消耗的时间:1856ms
100000次---gc前消耗内存:11251KB
100000次---gc消耗内存:134KB
100000次---gc前消耗的时间:1990ms
100000次---gc消耗的时间:11ms
100000次---消耗的时间:2001ms
1000000次---gc前消耗内存:12275KB
1000000次---gc消耗内存:-2231KB
1000000次---gc前消耗的时间:20161ms
1000000次---gc消耗的时间:10ms
1000000次---消耗的时间:20171ms
1000000次---gc前消耗内存:12275KB
1000000次---gc消耗内存:-2231KB
1000000次---gc前消耗的时间:20724ms
1000000次---gc消耗的时间:16ms
1000000次---消耗的时间:20740ms
分享到:
相关推荐
BPA气相色谱法测试溶液中双酚A的含量,学习GCHPLC等等
GC9307是一个262,144色的单芯片SoC驱动器,用于TFT液晶显示器,分辨率为240rgbx320点,包括720通道源驱动,320通道栅极驱动,172800字节的图形显示240rgbx320点的数据和电源电路。 GC9307支持并行8-/9-/16-/18位...
GC9305 240X320 TFT_LCD_DriverIC_datasheet GC9305屏ic规格书,用于驱动调试
操作人员通过VPN接入平行空间平台,利用平台仿真服务器连接5GC接入区进而访问5GC测试环境 部署意义 部署方案 5G网络平行空间靶场方案 5G网络安全解决方案全文共14页,当前为第11页。 目录 1 5G面临的新威胁 2 5G安全...
GC-PowerStation 特完美中文版,SMT导坐标和GERBER文件处理无需注册解压,经过测试放心使用可以
用于测试jvm gc调优-share-jvm-gc
mtk6739平台gc2385像头调试代码
GC-PowerStation 中文版,SMT导坐标和GERBER文件处理无需注册解压,经过测试放心使用可以用
gc0308_r16m_20161125版本测试ap6212a0+gc0308没有外层目录_20170307_1629.7z SC3817R开发板已经跑通AP6212A0版本的WIFI+BT 摄像头点亮gc0308。不过偏色!
GCViewer 1.36. 支持 JDK 1.8. 性能测试排查定位问题,分析调优过程中,会遇到要分析gc日志,人肉分析gc日志有时比较困难,相关图形化或命令行工具可以有效地帮助辅助分析。
GC9312,屏的初始化代码,本人测试过,绝对效果很好
GC-Prevue 是查看Gerber文件(PCB各层图形)的工具软件,并可打印出各层图,和精确测量各点的坐标。它是一个免费软件
CB-A2开发板测试记录 tina_astar-parrot_card06fpscamera+gc2145+显示_最终版本.img 1、DEBUG口正常/USB0可以接电脑连接ADB 2、LCD可以显示 root@TinaLinux:/bin# ./fb_test 3、USB1鼠标亮。必须接12V电源 4、U盘...
文中介绍了GC4016的主要特点和性能,给出了GC4016在软件无线电中的应用方法,同时给出了基于GC4016的数据采集卡和微机构成的双通道高速数据采集系统的设计方案和测试结果。
格科微gc5035的mtk平台android10.0驱动代码下载 AndroidQ 适用代码。测试OK的。这个是不带闪光灯和AF功能的
主要介绍了Java中垃圾回收器GC对吞吐量的影响测试,本文算是一个对垃圾回收器GC的优化文章,需要的朋友可以参考下
基于s5pv210的cmos摄像头驱动。摄像头为gc0307,采集的数据为yuyv,经测试,得到了图像。
jvm体系结构与GC调优,图文齐飞,方便理解,,非常适合入门的java工程师以及性能测试工程师阅读,欢迎大家下载
php-gc-基准测试对 PHP GC 检测的不同方法进行基准测试。内容bin : Docker 容器的包装脚本,用于运行任何测试并平均运行时间。 tests :(希望)执行 GC 的 PHP 脚本。 timing :一个可以针对beberlei:GCTiming ...
TPLINK-AP1907GC-PoE DC无线AP质量检测报告