简体   繁体   English

JMagick和JVM崩溃

[英]JMagick and JVM crashes

I'm using JMagick and have a simple Java class that loops over all images in a directory (and its sub directories), converting images into grayscale images. 我正在使用JMagick,并且有一个简单的Java类,该类循环遍历目录(及其子目录)中的所有图像,并将图像转换为灰度图像。

After my application runs for a while the JVM crashes. 我的应用程序运行了一段时间后,JVM崩溃了。 I believe the error message in the log is possibly suggesting that there were memory issues: 我相信日志中的错误消息可能表明存在内存问题:

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) j magick.MagickImage.writeImage(Lmagick/ImageInfo;)Z+0 j com.example.ImageGenerator.generateAlternativeImages(Ljava/io/File;Z)V+91 j com.example.ImageGenerator.main([Ljava/lang/String;)V+58 v ~StubRoutines::call_stub Java框架:(J =编译的Java代码,j =解释的,Vv = VM代码)j magick.MagickImage.writeImage(Lmagick / ImageInfo;)Z + 0 j com.example.ImageGenerator.generateAlternativeImages(Ljava / io / File; Z )V + 91 j com.example.ImageGenerator.main([Ljava / lang / String;)V + 58 v〜StubRoutines :: call_stub

--------------- PROCESS --------------- ---------------过程---------------

Java Threads: ( => current thread ) 0x0ab0c800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=1532, stack(0x0aec0000,0x0af10000)] 0x0ab0ac00 JavaThread "CompilerThread0" daemon [_thread_blocked, id=7304, stack(0x0ae70000,0x0aec0000)] 0x0aafe000 JavaThread "JDWP Command Reader" daemon [_thread_in_native, id=6836, stack(0x0ae20000,0x0ae70000)] 0x0aafc800 JavaThread "JDWP Event Helper Thread" daemon [_thread_blocked, id=7248, stack(0x0add0000,0x0ae20000)] 0x0aafa400 JavaThread "JDWP Transport Listener: dt_socket" daemon [_thread_blocked, id=6252, stack(0x0ad80000,0x0add0000)] 0x0aaee800 JavaThread "Attach Listener" daemon [_thread_blocked, id=2020, stack(0x0aca0000,0x0acf0000)] 0x0aaed400 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=7492, stack(0x0ac50000,0x0aca0000)] 0x0aada400 JavaThread "Finalizer" daemon [_thread_blocked, id=5400, stack(0x0ac00000,0x0ac50000)] Java线程:(=>当前线程)0x0ab0c800 JavaThread“低内存检测器”守护程序[_thread_blocked,id = 1532,stack(0x0aec0000,0x0af10000)] 0x0ab0ac00 JavaThread“ CompilerThread0”守护程序[_thread_blocked,id = 7304,stack(0x0aec70000,0 ] 0x0aafe000 JavaThread“ JDWP命令阅读器”守护程序[_thread_in_native,id = 6836,stack(0x0ae20000,0x0ae70000)] 0x0aafc800 JavaThread“ JDWP Event Helper Thread”守护进程[_thread_blocked,id = 7248,stack(0x0add0000,0x0ae20000D)传输侦听器:dt_socket“守护程序[_thread_blocked,id = 6252,堆栈(0x0ad80000,0x0add0000)] 0x0aaee800 JavaThread”附加侦听器“守护程序[_thread_blocked,id = 2020,堆栈(0x0aca0000,0x0acf0000)] 0x0aaed_cher_Java_” Signal Disal ,id = 7492,stack(0x0ac50000,0x0aca0000)] 0x0aada400 JavaThread“ Finalizer”守护程序[_thread_blocked,id = 5400,stack(0x0ac00000,0x0ac50000)]
0x0aad8c00 JavaThread "Reference Handler" daemon [_thread_blocked, id=5772, stack(0x0abb0000,0x0ac00000)] =>0x002b8000 JavaThread "main" [_thread_in_native, id=7020, stack(0x008c0000,0x00910000)] 0x0aad8c00 JavaThread“引用处理程序”守护程序[_thread_blocked,id = 5772,stack(0x0abb0000,0x0ac00000)] => 0x002b8000 JavaThread“ main” [_thread_in_native,id = 7020,stack(0x008c0000,0x00910000)]

Other Threads: 0x0aad5400 VMThread [stack: 0x0ab60000,0x0abb0000] [id=7720] 0x0ab0f000 WatcherThread [stack: 0x0af10000,0x0af60000] [id=6432] 其他线程:0x0aad5400 VMThread [堆栈:0x0ab60000,0x0abb0000] [id = 7720] 0x0ab0f000 WatcherThread [堆栈:0x0af10000,0x0af60000] [id = 6432]

VM state:not at safepoint (normal execution) VM状态:未处于安全点(正常执行)

VM Mutex/Monitor currently owned by a thread: None 当前由线程拥有的VM Mutex / Monitor:无

Heap def new generation total 960K, used 793K [0x029c0000, 0x02ac0000, 0x02ea0000) eden space 896K, 88% used [0x029c0000, 0x02a865f0, 0x02aa0000) from space 64K, 0% used [0x02aa0000, 0x02aa0000, 0x02ab0000) to space 64K, 0% used [0x02ab0000, 0x02ab0000, 0x02ac0000) tenured generation total 4096K, used 0K [0x02ea0000, 0x032a0000, 0x069c0000) the space 4096K, 0% used [0x02ea0000, 0x02ea0000, 0x02ea0200, 0x032a0000) compacting perm gen total 12288K, used 2219K [0x069c0000, 0x075c0000, 0x0a9c0000) the space 12288K, 18% used [0x069c0000, 0x06bead18, 0x06beae00, 0x075c0000) No shared spaces configured. 堆def新一代总计960K,使用793K [0x029c0000,0x02ac0000,0x02ea0000)伊甸园空间896K,88%使用了[0x029c0000,0x02a865f0,0x02aa0000)来自空间64K,0%使用了[0x02aa0000,0x02aa0000,0x02ab0000%)到空间64K已使用[0x02ab0000、0x02ab0000、0x02ac0000)终身生成总量4096K,已使用0K [0x02ea0000,0x032a0000,0x069c0000)空间4096K,已使用0%[0x02ea0000,0x02ea0000,0x02ea0200,0x032a0000)压实perx gen总计12288K,已使用0075 ,0x0a9c0000)空间12288K,已使用18%[0x069c0000、0x06bead18、0x06beae00、0x075c0000)未配置共享空间。

I've tried adding -Xmx options but figure this might not be the solution. 我尝试添加-Xmx选项,但认为这可能不是解决方案。 Any suggestions? 有什么建议么?

Thanks in advance. 提前致谢。

Your JVM crashed, -Xmx will not help. 您的JVM崩溃了, -Xmx将无济于事。 Can you try running with -Xint and see if you can reproduce the problem? 您可以尝试使用-Xint运行并查看是否可以重现该问题吗? This will tell the JVM to run without Hotspot, which means no dynamic compilation optimizations. 这将告诉JVM在没有 Hotspot的情况下运行,这意味着没有动态编译优化。 Which version of the JVM are you running with? 您正在运行哪个版本的JVM? If you can't reproduce the problem with -Xint , and you're using the latest JVM, you can try excluding only magick.MagickImage.writeImage from being compiled. 如果无法使用-Xint再现问题,并且使用的是最新的JVM,则可以尝试仅从编译中排除magick.MagickImage.writeImage

To exclude, create a file in the applications working directory called: 要排除,请在应用程序工作目录中创建一个文件:

.hotspot_compiler 

and add the line : 并添加以下行:

exclude magick/MagickImage writeImage

If you suspect it to be a memory issue then run the application with the option -XX:+HeapDumpOnOutOfMemoryError. 如果您怀疑它是内存问题,请使用选项-XX:+ HeapDumpOnOutOfMemoryError运行该应用程序。 This will create a heap dump if the application crashes due to OOME. 如果应用程序由于OOME崩溃而将创建堆转储。 You can then analyze the heap dump using tools like jhat or eclipse mat. 然后,您可以使用jhat或eclipse mat之类的工具分析堆转储。

You can also generate the heap dump of a running application using jmap and see the memory consumption using the tools suggested above to be sure of your suspicion. 您还可以使用jmap生成正在运行的应用程序的堆转储,并使用上面建议的工具查看内存消耗,以确保您的怀疑。

I found that you need to destroy every image copy you create. 我发现您需要销毁创建的每个映像副本。 Otherwise you create a memory leak. 否则会造成内存泄漏。 It is using JNI and I think there are mallocs which need to be freed. 它正在使用JNI,我认为有些malloc需要释放。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM