Fatal signal 6 when calling AbgrBuffer.allocate()
liviu-timar opened this issue · comments
Hello,
I am getting a crash with the following stacktrace. From what I can tell, it starts with a call to: AbgrBuffer.allocate(width, height)
in my code.
JNI DETECTED ERROR IN APPLICATION: non-zero capacity for nullptr pointer: 3686400
in call to NewDirectByteBuffer
from java.nio.ByteBuffer io.github.crow_misia.libyuv.Yuv.allocNativeBuffer(int)
at AbgrBuffer.allocate(width, height)
at io.github.crow_misia.libyuv.Yuv.allocNativeBuffer(Native method)
at io.github.crow_misia.libyuv.BufferExtKt.createByteBuffer(BufferExt.kt:21)
at io.github.crow_misia.libyuv.AbgrBuffer$Factory.allocate(AbgrBuffer.kt:110)
Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 3663 (CaptureThread), pid 2731 (o.android.debug)
~ Channel is unrecoverably broken and will be disposed!
I am doing this call for each frame of a video. The crash appears after 10 minutes of use.
Do you have any idea about what the problem could be? Let me know if you need more details.
Thank you,
Liviu
Seems to be a memory leak.
Instances should be reused instead of creating one for each frame.
Thanks for answering!
How can I reuse the buffer, taking into account that the width and height might change from a frame to another?
Maybe an implementation similar to this.
private var buffer: AbgrBuffer
fun onFrame(image: Image) {
if (image.width != buffer.width || image.height != buffer.height) {
buffer.close()
buffer = AbgrBuffer.allocate(image.width, image.height)
}
// image processing.
}
please reopen if there is more information.