Robert Green wrote: > 1) Are local variables ever affected by GC if they never call new, > either explicitly or implicitly? > -- I'm asking if I have a field that is "private ArrayList<Dog> > dogList;" and in my method, I say "ArrayList<Dog> dogList = > this.dogList;" - that doesn't have any impact on GC, correct? It's > just a pointer on the stack, right?
The pointer is on the stack. The ArrayList itself and its Dogs are on the heap. > 2) What about local variable arrays? Do those go in the heap (short > lived, GC) or on the stack? The array is on the stack. If the array is a primitive array (int[]), that covers everything. If the array is of objects (Dog[]), the Dog instances are from the heap. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Need help for your Android OSS project? http://wiki.andmob.org/hado --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

