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 absolute size of the object itself (not counting references to other objects), 2) the number of times the object has "survived" garbage collection, and (sometimes) 3) the class of the object.
On Oct 18, 11:57 am, Daniel Drozdzewski <[email protected]> wrote: > On Mon, Oct 18, 2010 at 5:54 PM, Daniel Drozdzewski > > > > <[email protected]> wrote: > > On Mon, Oct 18, 2010 at 5:40 PM, John Gaby <[email protected]> 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 have probably said that lack of finalize() does not mean that > > the memory has not been regained. > > > As Dan points out, finalizers don't necessary run. > > > If Android decided to kill the process running finished application, > > then it would simply do it on a system level, without trying to clean > > the heap within that VM first. > > > If you want to see finalizers at work, allocate many objects that you > > don't hold on to: > > > for(int i=0; i<10000; i++ ) { > > MyClass x = new MyClass(); > > } > > > ...and then call the following: > > > System.runFinalization(); > > System.gc(); > > > You should see your log statements. > > btw, it would also help, if you made MyClass a bit "heavier" say by > adding a member String and assigning to it some longish string literal > in MyClass' constructor. > > -- > Daniel Drozdzewski -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

