About the location of data structure and its inner objects
Lijie Xu
csxulijie at gmail.com
Mon Aug 26 09:04:41 UTC 2013
Thanks Thomas. I think it is as same as C++'s shallow copy.
On Mon, Aug 26, 2013 at 4:46 PM, Thomas Schatzl
<thomas.schatzl at oracle.com>wrote:
> Hi Xu,
>
> On Mon, 2013-08-26 at 16:20 +0800, Lijie Xu wrote:
> > Hi, folks. I’m confused with the concrete locations of the data
> > structure and its inner objects in the heap. The questions are below.
> >
> > A general question:
> >
> > If an object X is decided to be copied into old from new gen by GC,
> > all the objects which can be reached from X are copied into old too.
> > Or X’s retained set. Or this statement is wrong.
> >
>
> The Hotspot GCs only guarantee that a single object is in a particular
> generation. An object graph may span multiple generations.
>
> > Two concrete questions.
> >
> >Q1: Can an array such as byte[], String[] and Object[] span two
> >generations?
>
> No, the array itself is a single object, so it cannot span multiple
> generations.
> >
> > I think primitive arrays such as byte[] and int[] cannot span (e.g., a
> > part of the array exists in eden and the other part exists in old
> > space). For reference arrays such as Object[], the array itself cannot
> > span but the items in the arrays can span (i.e., some items exist in
> > new gen while others exist in old gen). I’m not sure if I’m right and
> > if String[] is as same as byte[].
>
> String[] is the same as an Object[].
> >
> > Q2: Can ArrayList, LinkedList, HashMap span two generations?
> >
>
> The separate objects cannot, the data structure with all its contents
> may span multiple generations.
>
> I.e. an ArrayList consists of (don't nail me on that) the ArrayList
> object itself, the object array object, and the referenced objects.
>
> So the ArrayList, the object array, and the referenced objects each will
> not span generations. However the parts themselves may be located in
> different generations.
>
> Hth,
> Thomas
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/hotspot-gc-dev/attachments/20130826/7697f2c5/attachment.htm>
More information about the hotspot-gc-dev
mailing list