`

OutOfMemory 测试

    博客分类:
  • JVM
 
阅读更多

 

 

 

/**
 *  可以触发内存溢出的类,生成headdump文件,分析溢出原因
 * 
 *  jvm参数:-Xmx100m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=D:\logs
 *  -XX:+HeapDumpOnOutOfMemoryError:在内存溢出时输出 headdump日志。
 *  -XX:HumpDumpPath=D:\logs dump文件路径,文件名为:java_pid${进程号}.hprof
 *
 *  输出的文件可以通过visualvm 或 EclipseMemoryAnalyzer 分析
 *
 */
public class OOM implements Runnable {
    byte [] data = null;
    public OOM(){
        data = new byte[1024*1024];
    }
    @Override
    public void run() {
        LockSupport.park();
    }

    public static void testOOM(){
        FixedThreadPool fixedThreadPool =  new  FixedThreadPool(1);
        //FixThreadPool内部是ThreadPoolExecutor
        for(int i=0;i<1000;i++){
            fixedThreadPool.execute(new OOM());
        }
    }
    public static void main(String args []){
        OOM.testOOM();
    }

}

  输出:

 

  

java.lang.OutOfMemoryError: Java heap space
Dumping heap to D:\logs\java_pid9344.hprof ...
Heap dump file created [98084663 bytes in 0.095 secs]
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at code.example.base.oom.OOM.<init>(OOM.java:10)
	at code.example.base.oom.OOM.testOOM(OOM.java:20)
	at code.example.base.oom.OOM.main(OOM.java:24)

 

 

  visualvm分析:

    

  

 

 

 

EclipseMemoryAnalyzer分析:



 

 

   分析结果:线程池中的队列占用空间过大导至内存溢出。

  • 大小: 107.2 KB
  • 大小: 58 KB
分享到:
评论

相关推荐

    解决Pytorch 训练与测试时爆显存(out of memory)的问题

    Pytorch 训练时有时候会因为加载的东西过多而爆显存,有些时候这种情况还可以使用cuda的清理技术... if out of memory in str(exception): print(WARNING: out of memory) if hasattr(torch.cuda, 'empty_cache'):

    pytorch模型提示超出内存RuntimeError: CUDA out of memory.

    跑模型时出现RuntimeError: CUDA out of memory.错误 查阅了许多相关内容,原因是:GPU显存内存不够 简单总结一下解决方法: 将batch_size改小。 取torch变量标量值时使用item()属性。 可以在测试阶段添加如下代码:...

    imageview,imageswitcher显示SD卡图片,并且解决out of memory问题

    Android imageview,imageswitcher显示SD卡上图片,并彻底解决imageview out of memory,记过这两天多次反复查找资源及测试,可以使用

    outOfMemory:如何使用-XX的示例

    安装 git clone https://github.com/jonboylailam/outOfMemory.gitcd outOfMemory./startTest.sh强调startTest.sh java -Xmx10m -cp classes -XX:OnOutOfMemoryError="./restart.sh" TestOutOfMemory

    Pytorch GPU显存充足却显示out of memory的解决方式

    今天在测试一个pytorch代码的时候显示显存不足,但是这个网络框架明明很简单,用CPU跑起来都没有问题,GPU却一直提示out of memory. 在网上找了很多方法都行不通,最后我想也许是pytorch版本的问题,原来我的pytorch...

    ios-摇一摇换皮肤.zip

    如果手机系统是iOS9.0或者以上,开发工具是XCode7.0以上,mac版本是OS X EI Capitan 10.11以上就可以直接真机测试,这里有一个真机测试地址http://ju.outofmemory.cn/entry/182050经过测试,能实现。如有问题,欢迎...

    如何规划性能测试流程

    如何规划性能测试流程.明天第二届互联网测试技术交流会将在杭州举行了,明天也去听听最新的技术动态...因为在代码修改的同时引入的大部分问题集中在OutOfMemory的问题上,所以我们需要将耐久测试放在首位。一般耐久测试

    饭客钻石-带网络验证带压力测试

    #define CTCN_OUTOFMEMORY NM_OUTOFMEMORY #define CTCN_SELCHANGE NM_FIRST #define CTCN_HIGHLIGHTCHANGE NM_FIRST + 1 #define CTCN_ITEMMOVE NM_FIRST + 2 #define CTCN_ITEMCOPY NM_FIRST + 3 #define CTCN_...

    endurox-go:Go应用程序服务器(ASG)

    GO应用程序服务器(ASG) 版本:2.0.0-使用对象模式API。 ASG是Golang的应用程序服务器,它可以处理Golang中的分布式事务。...建立和测试状态 作业系统 状态 作业系统 状态 作业系统 状态 RHEL / Oracle Linux 8 Ce

    MemTest86的内存测试源码

    of how the memory cells are laid out on the chip. In addition there is a never ending number of possible chip layouts for different chip types and manufacturers making this strategy impractical. ...

    Vollery加载大量图片

    大家都知道,图片加载是OOM(OutOfMemory)的常客,用手机测试2000条带图片ListView,完美运行,滑动无卡顿现象。

    DRRN在scale=2的条件下,训练出的模型文件,PSNR=37.74与论文中相同(最好)

    DRRN在scale=2的条件下,训练出的模型文件,PSNR=37.74与论文中相同(最好) ... 注意:1.模型权重文件( .pth)必须与DRRN的网络...亲测1920×1080在GPU上无论怎么测试肯定都会out of memory,缩小到512×319就不会了。

    POI读写海量Excel(详细解读)

    据笔者的测试,如果数据量大于3万条,每条8列的话,就会报OutOfMemory的错误。Excel2003中每个电子表格的记录数必须在65536以下,否则就会发生异常。目前还没有好的解决方案,建议对于海量数据写入操作,尽量使用...

    zabbix 监控、监视、控制

    监控:监视,控制随着用户的增多,服务随时可能会被系统oom out of memory 内存溢出 kill -9 mysql你怎么判断,web服务是因为用户访问过多,达到了瓶颈?还是程序代码bug导致的,内存过多?上线一个新网站: 压力...

    测试培训教材

    You can also view the system information that has been retrieved—such as CPU, memory, and processes running on the machine—and an image of the machine executing the system test. 6、测试用例设计、...

    KAIR:图像恢复工具箱 (PyTorch)。 DPIR、USRNet、DnCNN、FFDNet、SRMD、DPSR、ESRGAN的训练和测试代码

    USRNet、DnCNN、FFDNet、SRMD、DPSR、MSRResNet、ESRGAN、IMDN 的训练和测试代码 瑞士苏黎世联邦理工学院 新闻 (2021-06-03) : 增加人脸图像增强的测试... 提示 (2020-8) : 使用它可以避免out of memory问题。 新闻

    N-puzzles:使用最小优先级队列解决N个难题

    N个谜题笔记使用SearchNode类来记录Board,先前的SearchNode以及到其当前状态的移动次数,并且应该是先前的moves+1 打破平局的...45.txt (out of memory in test puzzle4x4-50.txt)puzzle00~50.txtall unsolvable参考

    二维广义S变换

    在2G内存下最大只能对84*84的图像进行处理,更大的图像会出现out of memory的问题。目前网上还没有这个程序,包括本站,pudn,ilovematlab都没有。把程序上传到这三个地方,望大家一起来改进它。

    数位板压力测试

    Out of Bounds Tracking 61 OBT Programming 61 Information Category 61 Turning OBT On and Off 61 B.3. Function Keys 62 FKEYS Programming 62 Information Category 62 B.4. Tilt 62 TILT Programming 63 ...

Global site tag (gtag.js) - Google Analytics