Out of Memory Issue in BoofCV

88 views
Skip to first unread message

jmoll...@inhancetechnology.com

unread,
Jun 13, 2018, 9:17:03 AM6/13/18
to BoofCV
We have been using BoofCV for a while now and are very happy with it, a huge thanks to the developers for this.

However, I am hoping you can help me with an issue we have had on one device (Samsung Galaxy C5 running Android Marshmallow 6.01) where it is reporting an OOM exception.

We are using version 0.26 of BoofCV, we haven't really seen this issue before, but we can move to BoofCV 0.30 if you think that would resolve this.

Here is the first example of it (stack trace)

Exception Backtrace:
1dalvik.system.VMRuntime.newNonMovableArrayNative Method
2android.graphics.Bitmap.nativeCreateNative Method
3android.graphics.Bitmap.createBitmapBitmap.java, line 975
4android.graphics.Bitmap.createBitmapBitmap.java, line 946
5android.graphics.Bitmap.createBitmapBitmap.java, line 913
6boofcv.android.gui.VideoImageProcessing.declareImagesVideoImageProcessing.java, line 37

and here is a different example, same device but happening in a different part of the code...

Exception Backtrace:
1boofcv.android.ConvertBitmap.declareStorageConvertBitmap.java, line 50
2boofcv.android.gui.VideoImageProcessing.declareImagesVideoImageProcessing.java, line 38


We don't have the device that is causing this so it's hard to know if here are other situations that may be causing this (phone storage full for example)

Do you have any ideas as to what could be causing this?  Any ideas why it is just on this device?

Thanks

John


Peter A

unread,
Jun 13, 2018, 1:30:48 PM6/13/18
to boofcv
I would add the image resolution and orientation to bug report meta data. In the demo application I see people jacking the resolution up way too high and exceeding available memory to just declare work space for the images.

You might want to consider upgrading to v0.30. It has support for Camera2 API and YUV420 format. Without knowing which algorithms you're using I don't know if there has been any memory optimization. Memory has been optimized for contour.



--
You received this message because you are subscribed to the Google Groups "BoofCV" group.
To unsubscribe from this group and stop receiving emails from it, send an email to boofcv+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
"Now, now my good man, this is no time for making enemies."    — Voltaire (1694-1778), on his deathbed in response to a priest asking that he renounce Satan.

jmoll...@inhancetechnology.com

unread,
Jun 14, 2018, 3:51:01 AM6/14/18
to BoofCV
HI Peter,

Thanks a million for your response.

When I specify the preview camera to use, I examine the largest resolution that the camera supports that is closest to the aspect ration of the screen.

It is nearly always 1920 * 1080, I have never seen it higher than this. We have tested across many devices using this resolution and have only seen an issue on the Samsung Galaxy C5 (we know this from the Firebase crash log, we don't have access to the exact device unfortunately). The code we are using is very similar to the code in the demo app.

You mentioned that memory has been optimised for contour? I don't follow what you mean by this. Could this have an impact?

I think we might bump the version up to 0.30 and see if that helps. Will it still support Camera 1 api though? 

Any other ideas you have would be very much appreciated. 

Thanks

John



To unsubscribe from this group and stop receiving emails from it, send an email to boofcv+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Peter A

unread,
Sep 9, 2018, 11:06:26 PM9/9/18
to boofcv
sorry for the very late reply.  See responses below:

On Thu, Jun 14, 2018 at 12:51 AM <jmoll...@inhancetechnology.com> wrote:
HI Peter,

Thanks a million for your response.

When I specify the preview camera to use, I examine the largest resolution that the camera supports that is closest to the aspect ration of the screen.

It is nearly always 1920 * 1080, I have never seen it higher than this. We have tested across many devices using this resolution and have only seen an issue on the Samsung Galaxy C5 (we know this from the Firebase crash log, we don't have access to the exact device unfortunately). The code we are using is very similar to the code in the demo app.

You mentioned that memory has been optimised for contour? I don't follow what you mean by this. Could this have an impact?

One example. Instead of having a seperate Point2D object for each point in the contour points are encoded in an array. Java bloats the size of individual objects so by having a single object you can save a lot of memory.
 
I think we might bump the version up to 0.30 and see if that helps. Will it still support Camera 1 api though? 

It should still work. It was moved to a new package but not deleted. It hasn't been tested beyond seeing that it still compiles.

John Mollaghan

unread,
Sep 10, 2018, 6:14:37 AM9/10/18
to boo...@googlegroups.com
Hi Peter,

Thanks for your reply.

The crash seems to be happening on the Galaxy C5, C7 and C9 models. We have just ordered a C7 device from EBay, so we should be able to test on that.

The crash seems to be coming from within the BoofCV library, specifically in the "VideoImageProcessing" class on line 37. Here is that class below, the second last line of the method is where it's happening (outputGUI = Bitmap.create...)

@Override
protected void declareImages( int width , int height ) {
super.declareImages(width,height);
output = Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888 );
outputGUI = Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888 );
storage = ConvertBitmap.declareStorage(output,storage);
}
I was wondering if I just reduced the resolution of the camera preview, could that fix this issue?
Any advice would be very welcome.
Thanks
John



Peter A

unread,
Sep 12, 2018, 10:56:28 AM9/12/18
to boofcv
That's a likely culprit. In the demo app I turned off crash reports from someone jacking the resolution way up to around 4048x3036. Maybe look up the total memory on those systems then estimate how much memory is needed at the resolution it crashed on?

In the latest SNAPSHOT there's an option to not double buffer. Meaning only one Bitmap image. The downside of that approach is that image shown to the user will some times be a composite of two different video frames.

John Mollaghan

unread,
Sep 12, 2018, 11:03:12 AM9/12/18
to boo...@googlegroups.com
How can I get access to that latest SNAPSHOT? We are using Gradle, at the moment we look at...
org.boofcv:recognition:0.26
We have ordered a phone to test with and we should get it this week. If I were to switch off the double buffering, would it make a big difference to the frame rate in the preview?  Also, where in the code would I switch this off?

Thanks again,

John

John Mollaghan

unread,
Sep 12, 2018, 11:12:33 AM9/12/18
to boo...@googlegroups.com
HI Peter,

One more thing, how can I access the 0.30 version of the libraries using Gradle?

This won't work for me...
org.boofcv:recognition:0.29

or

org.boofcv:recognition:0.30


Peter A

unread,
Sep 14, 2018, 12:03:07 PM9/14/18
to boofcv

module names change to avoid potential conflict with other libraries

org.boofcv:boofcv-recognition:0.30

Peter A

unread,
Sep 14, 2018, 12:12:24 PM9/14/18
to boofcv
makes very little difference in frame rate. More of a memory optimization. In 0.27 NV21 -> RGB got speed up about 1.9x. That optimization has been brought over to the camera 2 code that's new in 0.30.

If you want to mess with the SNAPSHOT check out
 

It tells you how to build and install all the dependencies. You can check out the new camera2 API example code here


Michael Wood

unread,
Sep 16, 2018, 1:12:14 AM9/16/18
to boo...@googlegroups.com
Looks like the Galaxy C5 has 4GB of RAM:


On 12 September 2018 at 16:56, Peter A <peter....@gmail.com> wrote:
That's a likely culprit. In the demo app I turned off crash reports from someone jacking the resolution way up to around 4048x3036. Maybe look up the total memory on those systems then estimate how much memory is needed at the resolution it crashed on?

In the latest SNAPSHOT there's an option to not double buffer. Meaning only one Bitmap image. The downside of that approach is that image shown to the user will some times be a composite of two different video frames.
On Mon, Sep 10, 2018 at 3:14 AM John Mollaghan <jmollaghan@inhancetechnology.com> wrote:
Hi Peter,

Thanks for your reply.

The crash seems to be happening on the Galaxy C5, C7 and C9 models. We have just ordered a C7 device from EBay, so we should be able to test on that.

The crash seems to be coming from within the BoofCV library, specifically in the "VideoImageProcessing" class on line 37. Here is that class below, the second last line of the method is where it's happening (outputGUI = Bitmap.create...)

@Override
protected void declareImages( int width , int height ) {
super.declareImages(width,height);
output = Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888 );
outputGUI = Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888 );
storage = ConvertBitmap.declareStorage(output,storage);
}
I was wondering if I just reduced the resolution of the camera preview, could that fix this issue?
Any advice would be very welcome.
Thanks
John




On Mon, 10 Sep 2018 at 04:06, Peter A <peter....@gmail.com> wrote:
sorry for the very late reply.  See responses below:
To unsubscribe from this group and stop receiving emails from it, send an email to boofcv+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
"Now, now my good man, this is no time for making enemies."    — Voltaire (1694-1778), on his deathbed in response to a priest asking that he renounce Satan.

--
You received this message because you are subscribed to the Google Groups "BoofCV" group.
To unsubscribe from this group and stop receiving emails from it, send an email to boofcv+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "BoofCV" group.
To unsubscribe from this group and stop receiving emails from it, send an email to boofcv+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
"Now, now my good man, this is no time for making enemies."    — Voltaire (1694-1778), on his deathbed in response to a priest asking that he renounce Satan.

--
You received this message because you are subscribed to the Google Groups "BoofCV" group.
To unsubscribe from this group and stop receiving emails from it, send an email to boofcv+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Michael Wood <esio...@gmail.com>

John Mollaghan

unread,
Sep 17, 2018, 4:38:31 AM9/17/18
to boo...@googlegroups.com
It's very strange, our app is working away fine on some very old phones with limited RAM. I think the problem may be because the C5 has such a high resolution camera.

I'll update to the latest version of the library and see if it helps.

Thanks

On Sun, 16 Sep 2018 at 06:12, Michael Wood <esio...@gmail.com> wrote:
Looks like the Galaxy C5 has 4GB of RAM:

On 12 September 2018 at 16:56, Peter A <peter....@gmail.com> wrote:
That's a likely culprit. In the demo app I turned off crash reports from someone jacking the resolution way up to around 4048x3036. Maybe look up the total memory on those systems then estimate how much memory is needed at the resolution it crashed on?

In the latest SNAPSHOT there's an option to not double buffer. Meaning only one Bitmap image. The downside of that approach is that image shown to the user will some times be a composite of two different video frames.



--
Michael Wood <esio...@gmail.com>

John Mollaghan

unread,
Sep 17, 2018, 4:42:18 AM9/17/18
to boo...@googlegroups.com
Thanks Peter,

We are stuck with the Camera 1 api, because we need to support all the way back to Android 4.4.4. For this reason we just use Camera 1.

You mentioned that it would be a good idea for me to NOT use double buffering. How would I do this in the code please?

Thanks

John
Reply all
Reply to author
Forward
0 new messages