Is there a way to calculate if ram needed for an image exceeds the available memory?

mistermentality

Active Member
Licensed User
Longtime User
I am working on an app that uses agrahams excellent jpeg library to load in and edit a jpeg.

Larger jpegs crash the app with an out of memory error because obviously on a smaller device such as a phone you cannot allocate say 20 Mb for processing a jpeg (which a pic taken by a digital camera can exceed, based on logs of processing tests I have done done in b4a).

Is there a way to discover the amount of free ram on the device and then to calculate the amount of memory the picture would take (it doesn't have to be an exact calculation, a rough idea would help)?

Thanks

Dave
 

mistermentality

Active Member
Licensed User
Longtime User
It is not possible. However maybe you can prevent your program from loading very large images which are likely to cause OOM errors.

Thanks for the quick reply, I am currently popping a message box up to warn the user (if the image filesize is of a certain value or greater) that processing the image may cause the application to run out of memory and exit with an error so this helps. Thanks again :)

Dave
 
Upvote 0

gemasoft

Member
Licensed User
Longtime User
Good gente.Tengo a problem with this message: The application? (???.??.??) Process has stopped unexpectedly.
I have followed in the LOG but I do not give any specific information, my question is whether the problem is because my application uses 80x80px PNG images to form the graphical environment of various views and activities ..
 
Upvote 0
Top