-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System unexplained termination #1716
Comments
This problem bothered me and made it impossible for me to continue |
I want to know the solution and the cause of this exception |
That probably just means that the memory of the Mat that you're trying to convert has already been deallocated. In that case, you'll need to find where in your code that happens and fix this. |
BufferedImage image = Java2DFrameUtils.toBufferedImage(mat.clone()); When I use it like this, the exception still exists |
When I looked at the previous problem, I found that java2dframeutils is not thread safe. I read the source code and found that synchronized is added. I don't think it's the problem |
I didn't take the initiative to release the mat object. I think the JVM system took the initiative to recycle it. I don't know how to control it |
Right, this should probably be protected by a PointerScope. |
Do you use softreference to operate? When the memory is insufficient, the GC is triggered to reclaim the memory and release it |
|
No, please try like this: try (PointerScope scope = new PointerScope()) {
image = Java2DFrameUtils.toBufferedImage(mat);
} |
The parent class of mat object implements the autoclosable interface, and pointerscope object also implements the autoclosable interface. After try, the close() method will be called. Sorry, I don't know the difference between mat and pointerscope in this code |
Ok, that's fine, please try like this: try (Mat c = mat.clone(); PointerScope scope = new PointerScope()) {
image = Java2DFrameUtils.toBufferedImage(c);
} |
Thank you, but when I use mat to put it in the linkedblockingqueue and another thread consumes, the memory is still full and the JVM is killed by the system |
Make sure to deallocate them manually with something like Mat.close(). |
I don't know munmap_ Chunk(): invalid pointer: the reason for this problem |
That probably means you're trying to use a Mat that is already deallocated.
|
Hello, when I use it like this while(true){
SendRstpInfo sendRstpInfo = linkedBlockingDeque.poll(50, TimeUnit.MILLISECONDS);
try (Mat mat = sendRstpInfo.getJpg(); Mat c = mat.clone(); PointerScope scope = new PointerScope()) {
Frame frame = drawRect(mat, dataPack.getPacks());
if (frame != null) {
recorder.record(frame);
}
}
}
public Frame drawRect(Mat mat, List<Pack> packs) {
BufferedImage image = null;
try {
log.info("开始转换成BufferedImage!!")
image = Java2DFrameUtils.toBufferedImage(mat)
log.info("转换BufferedImage 成功!!");
return addSubtitle(image, packs);
} catch (Exception e) {
e.printStackTrace();
}
} |
…prevent premature deallocations (issue #1716)
I think I've fixed this issue in commit e0d0f5c. Please give it a try with the snapshots: http://bytedeco.org/builds/ If you're still experiencing a crash with JavaCV 1.5.7-SNAPSHOT though, please let me know! Thanks for reporting |
The fix has been released with JavaCV 1.5.7. Please let me know if you're still having issues with this though, thanks! |
…prevent premature deallocations (issue bytedeco#1716)
When I'm using Java2DFrameUtils.toBufferedImage(mat); Method, an exception causes the service to exit. The exception information of the error is
`#
A fatal error has been detected by the Java Runtime Environment:
SIGSEGV (0xb) at pc=0x00007f3d4d55fa41, pid=21614, tid=0x00007f3c5c7e4700
JRE version: Java(TM) SE Runtime Environment (8.0_291-b10) (build 1.8.0_291-b10)
Java VM: Java HotSpot(TM) 64-Bit Server VM (25.291-b10 mixed mode linux-amd64 compressed oops)
Problematic frame:
J 6355 C2 org.bytedeco.javacv.Java2DFrameConverter.flipCopyWithGamma(Ljava/nio/ByteBuffer;IILjava/nio/ByteBuffer;IIZDZI)V (635 bytes) @ 0x00007f3d4d55fa41 [0x00007f3d4d55eee0+0xb61]
Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
An error report file with more information is saved as:`
The text was updated successfully, but these errors were encountered: