Mat::t() Android, After give time gives out of the memory (Bug #4262)
Description
1 public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
2 Mat mRgba = inputFrame.rgba().clone();
3 Mat mRgbaT = mRgba.t();
4 Core.flip(mRgba.t(), mRgbaT, 1);
5 Imgproc.resize(mRgbaT, mRgbaT, mRgba.size());
6 return mRgbaT;
7 }
04-04 16:39:16.723 1115-1834/com.bitflags.kioba.augmented D/FpsMeter﹕ 6.42 FPS@1280x960
04-04 16:39:16.735 1115-1115/com.bitflags.kioba.augmented D/JavaCameraView﹕ Preview Frame received. Frame size: 1843200
04-04 16:39:16.801 1115-1115/com.bitflags.kioba.augmented D/JavaCameraView﹕ Preview Frame received. Frame size: 1843200
04-04 16:39:16.841 1115-1834/com.bitflags.kioba.augmented D/CameraBridge﹕ mStretch value: 1.125
04-04 16:39:16.853 1115-1834/com.bitflags.kioba.augmented D/FpsMeter﹕ 6.42 FPS@1280x960
04-04 16:39:16.868 1115-1115/com.bitflags.kioba.augmented D/JavaCameraView﹕ Preview Frame received. Frame size: 1843200
04-04 16:39:16.885 1115-1834/com.bitflags.kioba.augmented E/cv::error()﹕ OpenCV Error: Insufficient memory (Failed to allocate 4915204 bytes) in void* cv::OutOfMemoryError(std::size_t), file /hdd2/buildbot/slaves/slave_ardbeg1/50-SDK/opencv/modules/core/src/alloc.cpp, line 52
04-04 16:39:16.886 1115-1834/com.bitflags.kioba.augmented E/org.opencv.core.Mat﹕ Mat::n_1t() caught cv::Exception: /hdd2/buildbot/slaves/slave_ardbeg1/50-SDK/opencv/modules/core/src/alloc.cpp:52: error: (-4) Failed to allocate 4915204 bytes in function void* cv::OutOfMemoryError(std::size_t)
04-04 16:39:16.898 1115-1834/com.bitflags.kioba.augmented E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-1798
Process: com.bitflags.kioba.augmented, PID: 1115
CvException [org.opencv.core.CvException: cv::Exception: /hdd2/buildbot/slaves/slave_ardbeg1/50-SDK/opencv/modules/core/src/alloc.cpp:52: error: (-4) Failed to allocate 4915204 bytes in function void* cv::OutOfMemoryError(std::size_t)
]
at org.opencv.core.Mat.n_t(Native Method)
at org.opencv.core.Mat.t(Mat.java:2353)
at com.bitflags.kioba.augmented.surface.onCameraFrame(surface.java:119)
at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:387)
at org.opencv.android.JavaCameraView$CameraWorker.run(JavaCameraView.java:328)
at java.lang.Thread.run(Thread.java:818)
04-04 16:39:16.934 1115-1635/com.bitflags.kioba.augmented E/IMemory﹕ cannot map BpMemoryHeap (binder=0x9f60b3c0), size=11059200, fd=35 (Out of memory)
04-04 16:39:16.934 1115-1635/com.bitflags.kioba.augmented A/libc﹕ Fatal signal 11 (SIGSEGV), code 1, fault addr 0xffffffff in tid 1635 (Binder_4)
04-04 16:39:16.941 1115-1115/com.bitflags.kioba.augmented D/JavaCameraView﹕ Disconnecting from camera
04-04 16:39:16.941 1115-1115/com.bitflags.kioba.augmented D/JavaCameraView﹕ Notify thread
04-04 16:39:16.941 1115-1115/com.bitflags.kioba.augmented D/JavaCameraView﹕ Wating for thread
History
Updated by Karoly Somodi almost 10 years ago
A newer chrash i guess im not alloved to use Mat::t() ...
it is actually 2.4.10 target but cnat set it anywhere ...
04-04 20:57:41.406 9852-10581/com.bitflags.kioba.augmented E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-2240
Process: com.bitflags.kioba.augmented, PID: 9852
CvException [org.opencv.core.CvException: cv::Exception: /hdd2/buildbot/slaves/slave_ardbeg1/50-SDK/opencv/modules/core/src/alloc.cpp:52: error: (-4) Failed to allocate 8294404 bytes in function void* cv::OutOfMemoryError(std::size_t)
]
at org.opencv.core.Mat.n_t(Native Method)
at org.opencv.core.Mat.t(Mat.java:2353)
at com.bitflags.kioba.augmented.surface.onCameraFrame(surface.java:120)
at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:387)
at org.opencv.android.JavaCameraView$CameraWorker.run(JavaCameraView.java:328)
at java.lang.Thread.run(Thread.java:818)
Updated by Steven Punte almost 10 years ago
I had success at resolving this problem by adding Mat.release() to every OpenCV Matrix object at of course locations where each object was no longer needed. I currently operate on release 2.4.9.
Updated by Maksim Shabunin over 9 years ago
Issue has been transferred to GitHub: https://github.com/Itseez/opencv/issues/4961