Re: [android-developers] Re: Memory leaks when using bitmaps in android

2011-12-22 Thread Miguel Morales
Working with bitmaps is a little hard on Android. One thing to do is to resize or pack them so that they take up less memory. Another thing you may want to look into is to reuse the bitmap object/memory. You may have to do this in native though. As other have pointed out System.gc() just gives the

Re: [android-developers] Re: Memory leaks when using bitmaps in android

2011-12-20 Thread James Black
You should work on getting a smaller example to demonstrate as this is too much code to read through. It may also help you solve the problem yourself. On Dec 20, 2011 3:21 PM, "shyama" wrote: > I realised that when when I made a call to System.gc() right after the > bitmao..recycle() call the he

Re: [android-developers] Re: Memory Leaks

2010-10-19 Thread Daniel Drozdzewski
On Tue, Oct 19, 2010 at 11:57 AM, Tom Gibara wrote: > >> What if the system decides to send KILL to a process running >> some background task (application) to regain memory. > > In that case, the object's memory has not been reclaimed from the heap, the > heap has been destroyed. These are two dif

Re: [android-developers] Re: Memory Leaks

2010-10-19 Thread Kostya Vasilyev
John, You could try forcing GC (for debugging) by creating a thread that allocates memory in a loop, something like this: for (;;) { byte[] buf = new byte[100 * 1024]; Log.i(TAG, "new buf: " + buf); Thread.Sleep(100); } Note that references to these byte buffers are not kept around, but the

Re: [android-developers] Re: Memory Leaks

2010-10-19 Thread Tom Gibara
> What if the system decides to send KILL to a process running > some background task (application) to regain memory. In that case, the object's memory has not been reclaimed from the heap, the heap has been destroyed. These are two different things: if the VM's process is terminated, it's no lon

Re: [android-developers] Re: Memory Leaks

2010-10-19 Thread Daniel Drozdzewski
On Tue, Oct 19, 2010 at 1:25 AM, Tom Gibara wrote: > >> It is possible that the finalize() has been called at much later point. >> >> I should have probably said that lack of finalize() does not mean that >> >> the memory has not been regained. > > This isn't correct. If an object is an instance o

Re: [android-developers] Re: Memory Leaks

2010-10-19 Thread Daniel Drozdzewski
On Mon, Oct 18, 2010 at 6:21 PM, DanH wrote: > I doubt that adding content to the object would make it any more > likely to be collected.  The garbage collector doesn't generally > "weigh" objects as to whether they should be collected or not.  The > only differentiating factors are 1) the absolut

Re: [android-developers] Re: Memory Leaks

2010-10-18 Thread Tom Gibara
> It is possible that the finalize() has been called at much later point. I should have probably said that lack of finalize() does not mean that the memory has not been regained. This isn't correct. If an object is an instance of a class with a non-trivial finalize method, then the object's mem

Re: [android-developers] Re: Memory Leaks

2010-10-18 Thread Kostya Vasilyev
If I can make one more suggestion since you mention bitmaps It might be useful to add explicit Java methods to clean up your objects that hold references to bitmaps, and call Bitmap.recycle(). This method immediately frees up the memory allocated to hold bitmap bits, leaving only the

Re: [android-developers] Re: Memory Leaks

2010-10-18 Thread Kostya Vasilyev
18.10.2010 20:40, John Gaby пишет: What I really want is a way to find out whether an object has been freed (or will be freed) or not. I believe that I must have objects that are not being freed, and I would like to try and identify them. This might be useful: http://ttlnews.blogspot.com/2010

Re: [android-developers] Re: Memory Leaks

2010-10-18 Thread Daniel Drozdzewski
btw^2 Rather than assigning the same literal in the constructor, create new String each time around the same literal: /* * My Class */ package com.gabysoft.memoryleak; import android.util.Log; public class MyClass extends Object { String balast; MyClass() { balast = new Stri

Re: [android-developers] Re: Memory Leaks

2010-10-18 Thread Daniel Drozdzewski
On Mon, Oct 18, 2010 at 5:54 PM, Daniel Drozdzewski wrote: > On Mon, Oct 18, 2010 at 5:40 PM, John Gaby wrote: >> Thanks for the input.  I am a little confused about your comment: >> >> 'The fact that you did not see the log from finalize() does not mean >> it did not happen.' > > It is possible

Re: [android-developers] Re: Memory Leaks

2010-10-18 Thread Daniel Drozdzewski
On Mon, Oct 18, 2010 at 5:40 PM, John Gaby wrote: > Thanks for the input.  I am a little confused about your comment: > > 'The fact that you did not see the log from finalize() does not mean > it did not happen.' It is possible that the finalize() has been called at much later point. I should hav

Re: [android-developers] Re: Memory leaks in activities and views

2010-05-18 Thread Kostya Vasilyev
You could also be more proactive with releasing unneeded objects. Rather than doing it in finalize (if that is how you do it), do object cleanup in onPause. 18.05.2010 23:12 пользователь "ls02" написал: Yes, this is really what I need. Though I see that periodically my singleTask activity contsr

Re: [android-developers] Re: Memory leaks in activities and views

2010-05-18 Thread TreKing
On Tue, May 18, 2010 at 12:04 PM, ls02 wrote: > nohistory does not work. The app runs out of memory. Have you looked at the singleTask flag? - TreKing - Chicago transit tracking app for Android-powe