Android Question jRDC 2.1 Error : dbrequestmanager_bytestoimage java.lang.OutOfMemoryError

Anser

Well-Known Member
Licensed User
Longtime User
Hi,

I am getting the following error in jRDC2.1
dbrequestmanager_bytestoimage (java line: 52)
java.lang.OutOfMemoryError

Here is the full error log:-

dbrequestmanager_bytestoimage (java line: 52)
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
at android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:620)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:634)
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:519)
at com.popularhyundai.publicapp.dbrequestmanager._bytestoimage(dbrequestmanager.java:52)
at com.popularhyundai.publicapp.homepage._buildschemeslist(homepage.java:756)
at com.popularhyundai.publicapp.homepage._reqmanager_result(homepage.java:950)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.keywords.Common$5.run(Common.java:996)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)

Here is the query being used. The Columns Picture and Picture_Small are MEDIUMBLOB type columns
B4X:
sql.schm_list_homepage=SELECT ID, Title, Picture, Picture_Small FROM mas_schemes_offers

When I run the code
B4X:
reqManager.PrintTable(result)
It gives the following output

Tag: GetActiveSchemes, Columns: 4, Rows: 12
ID Title Picture Picture_Small
1 Description 01 [B@b4dda1b8 [B@b4de78b0
2 Description 02 [B@b4dfcf08 [B@b4e0d7a0
3 Description 03 [B@b4e254c0 [B@b4e3afe8
4 Description 04 [B@b4e50180 [B@b4e67f78
5 Description 05 [B@b4e82850 [B@b4e9b818
6 Description 06 [B@b4eb1660 [B@b4ebe960
7 Description 07 [B@b4ed0d38 [B@b4f48d08
8 Description 08 [B@b4f4c7c8 [B@b500ee58
9 Description 09 [B@b50244b0 [B@b503c2a8
10 Description 10 [B@b5056b80 [B@b5063e80
11 Description 11 [B@b5076258 [B@b508bd80
12 Description 12 [B@b50a0f18 [B@b50b9ee0

The B4A code that generates the error is given below
B4X:
Dim Buffer() As Byte
Dim oBitmap As Bitmap
Buffer = records(result.Columns.Get("Picture"))
If Buffer = Null Then
Else
    'The next line generates error
    oBitmap = reqManager.BytesToImage(Buffer)
End If

This was working fine till few days back and I have used similar code in other projects and everywhere it worked fine.

The error occurs only for few records ie records with ID 5,7 and 9

To find out whether there are any issue with the data of these records, I checked reading the Image data (Column named Picture) on other programming languages and found that it is working fine and the images are displayed properly.

Can anyone tell me why this error and how to resolve this issue.

Regards
Anser
 

Anser

Well-Known Member
Licensed User
Longtime User
The problem is resolved.

The problem is only when I run my app on the Android Emulator, so I assume that this may be because of the limited resources of the android emulator.

Anyway I would like to know whether any solution is there to track and control this error (Out of Memory Error). This may happen if my app is run on very low end devices.

The same app was not working on my real device too. As this was not working on my real device, to debug, I used the emulator. The emulator took me to a different direction. All these issues were just because of my today's windows updates. Somehow this update blocked the port used by jRDC on my PC. I disabled the firewall and the app on my real device started working fine.

I think that I need some rest;)
 
Upvote 0
Top