On Mon, May 25, 2009 at 1:34 PM, Mark Murphy <mmur...@commonsware.com> wrote:
>> 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.

Actually, all array contents live on the heap, whether the contents
are primitives or objects, and a simple reference to the array will be
on the stack in a local variable. For example:

    static void blort() {
        int[] arr = { 1, 2, 3 };
        // "here"
    }

At "here," the stack frame for blort() will contain a single local
variable reference for arr, which will point at a freshly-allocated
array on the heap containing { 1, 2, 3 }.

-dan

--~--~---------~--~----~------------~-------~--~----~
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-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to