On Oct 18, 8:58 am, John Gaby <[email protected]> wrote: > public void onCreate(Bundle savedInstanceState) > { > super.onCreate(savedInstanceState); > > MyClass mc = new MyClass(); > mc = null; > > setContentView(R.layout.main); > > System.gc(); > }
An optimizing compiler could choose to drop the "mc = null;" statement, because the value of "mc" is never used after that. The Dalvik GC is currently type-precise but not live-precise, which means that even if the assignment does happen it's possible that there's still a register sitting around with a copy of the reference in it. The VM knows it's a reference, but doesn't know that it'll never be used again, so it's still included in the root set. Creating "trivial" GC examples is rarely trivial. :-) -- 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

