2

I'm using in my application an external jar-library, which is working with bitmaps. This causes an out of memory exception in my application. This kind of problem is described in following issue: http://code.google.com/p/android/issues/detail?id=8488

Once OOME occurs, an activity crashes, application is still going runing, memory will be free, but the wifi-connection will be lost.

Is there the way to get memory free before activity crashes? Probably, I should say, I have no access to bitmaps, which are using by the library. I also tried to call System.gc() in onPause and onDestroy, but that doesn't help.

Why would be memory free when activity crashes?

What did happen with wi-fi-connection?

Thank you

upd

this library is osmdroid

2
  • It'd help if you documented the .jar usage. Maybe you're not calling the API which frees/recycles the bitmaps. Or maybe you're decoding large images at their native resolution and it's just too much. Commented Feb 8, 2011 at 11:38
  • This bibliothek is osmdroid, i haven't seen any api which frees / recycles the bitmaps. But I will take another look Commented Feb 8, 2011 at 14:59

1 Answer 1

1

Try to extend Application class with your own (need to be declared AndroidManifest.xml). In those Application class there's one method Application.onLowMemory() - which has to be called on low memory. You can override this method and try to release unnecessary resources. Probably it will be usefull.

Sign up to request clarification or add additional context in comments.

2 Comments

Ok, but how can i release unnecessary resources of the library (btw., it's osmdroid)?
@Mur You need to call the clear method of your MapTileCache instance. I found it easier to make the MapTileCache instance a singleton and then call in the body of onLowMemory implementation MapTileCache.getInstance().clear(); @barmaley that's a very right suggestion, thanx.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.