Re: [android-developers] Re: Total Available memory for Memory Management logic.
On Wed, Apr 25, 2012 at 8:16 PM, Anieeh <animesh.android@gmail.com> wrote:
>
> Thanks Latimerius
> For your quick reply, yes i need an early warning (even before you
> actually run out of heap)
> because after an error occur "OutOfMemory" and then if i release some
> memory and restart the
> same operation it will give the same error since the GC wont collect
> the free memory as soon as
> we released some bitmap memory. And the same will happen over and
> over, and it increase the
> overhead of re-Starting the same task.
I see - makes sense I guess. What if you ran System.gc() after you
release some bitmaps? I know it makes no guarantees and using it is
generally frowned upon, but I would probably at least give it a try.
I suspect none of the ways you could possibly handle this will be very
solid, it's mostly more or less dodgy techniques as far as I know.
The very presence of a GC makes it rather hard to tell how much memory
is left.
Depending on your situation I'd probably still stick with my earlier
suggestion. Make your operations explicit in your program (package
them up in classes behind an interface like Runnable) and queue them.
Iterate through the queue running the operations and catching
OutOfMemoryError. If it occurs free some bitmaps and perhaps try
running System.gc() afterwards. Leave the operation that threw in the
queue. Repeat until no more OutOfMemoryError.
I can imagine a lot of unwelcome corner cases that would complicate
the scenario, however this way at least you get the restarting pretty
much for free.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home