JNI-hazard问题
JMagick使用JNI技术调用ImageMagick,存在JNI-hazard问题。不适合在长时间运行的Web应用程序使用ImageMagick +Jmagick,可能导致JVM崩溃。
我就在项目中遇到过,Tomcat在跑了数天后会crash,异常内容为:magick.MagickException: Unable to retrieve handle 。
从表象看,应该是没有释放ImageMagick的句柄导致的,查找API后发现程序中没有调用:magick.MagickImage.destroyImages() Called by finalize to deallocate the image handle。 在程序加上本方法,情况有所改善,大概在十多天后出现了一次tomcat进程crash。并不能根本解决问题。
建议使用IM4JAVA。
在JMagick的邮件列表中找到一份我认为有价值的邮件
The "JNI hazard" here is that if something you use (f.ex libtiff for reading TIFF files) has a memory bug then it can make your whole JVM crash. Thats of course frustrating and therefore its great to have im4java around, which starts IM as an external process, so JVM crashes are avoided. * * Coolest thing would be if JMagick and im4java could have the same API so it was easy to switch depending on luckyness. Ive asked the author of im4java to attemt to be as compatible as possible, but as im4java is very much different internally its limited how much can be done in that direction. If you don't like the risk, stick to im4java. If your want optimal performance give JMagick a try. And, its not JMagick that is buggy, its what it depends on (hereunder IM) that is not always (memory) bug free on long running processes. I also have never seen a mismatch between JMagick binary and ImageMagick binaries leading to crashes.
IM4JAVA官方文档也有相关说明:
1.1. What exactly do you mean with JNI-hazard? Running native code using JNI from within java always imposes additional risks. The JVM is no longer sandboxed, so there might be some security issues. In addition, there could be errors like memory leaks or memory corruption within the JNI-layer (JMagick) or within the native code (ImageMagick). This is especially dangerous for long running processes (typically web-application-servers). Memory corruption or a segmentation fault (maybe triggered by a intentionally manipulated image) might bring down the whole server. On the other side, in reality the situation is not as bad as it sounds above. JMagick is well tested, and for standard use-cases it prooves to be very stable. Some additional information is available on the JMagick-users mailing list where this topic has been discussed to some detail.
相关推荐
jmagick-6.2.4-1-IM-6.2.5.zip
jmagick-win-6.3.9 java 图片裁剪工具
JMagick-6.0.4-0.tar 下载
jmagick.jar,ImageMagick.exe,测试过,可用
JMagick是一个开源API,利用JNI(Java Native Interface)技术实现了对 ImageMagick API的Java访问接口,因此也将比纯Java实现的图片操作函数在速度上要快。
jmagick java 图像处理jmagick java 图像处理jmagick java 图像处理jmagick java 图像处理jmagick java 图像处理
压缩包在java下使用jmagick的所有必需工具和安装包,还有使用实例。
java web中Magick图形处理源代码
tar xzvf jmagick-6.4.0.tar.gz (# chmod * 否则这个包内的文件无权限执行) autoconf ./configure --prefix=/opt/JMagick --with-magick-home=/opt/ImageMagick --enable-share --enable-static --with-java-home=...
下载ImageMagick-6.3.9-0-Q8-windows-dll.exe和jmagick-win-6.3.9-Q8.zip 安装ImageMagick-6.3.9-0-Q8-windows-dll.exe,按照网上说法把安装后根目录下的所有.dll文件拷贝到C:\WINDOWS\system32下。不过没拷贝成功。...
NULL 博文链接:https://shikonglaike.iteye.com/blog/870553
里面包括jmagick 所需所有文件,jmagick.dll,jmagick.jar 还有安装文件, 以及linux安装说明! jmagick jmagick.jar jmagick资料 jmagick缩略图 jmagick jmagick.jar jmagick资料 jmagick缩略图
Jmagick32位的和Jmagick64位的Jmagick.dll,Jmagick.jar 图片处理必备工具
内容:【ImageMagick-6.3.9-0-Q16-windows-dll.exe安装文件】【jmagick-win-6.3.9-Q16内有jar包和dll文件】【java代码示例】 用法: 1、先安装ImageMagick,重启电脑。 2、将jmagick.dll文件拷贝到JAVA_HOME\bin目录...
ImageMagick-6.3.9+jmagick组合,此组合已测试通过
压缩包在java下使用jmagick的所有必需工具和安装包,还有使用实例。
jmagick.zip
jmagick.jar 及用法。。。。。。。。。。
jmagick.jar java图像应用
jmagick image generate or operator library