views:

26

answers:

1

are the new objets assigned from eden space or eden + fromSurvivor space ? can free space in from survivor space be also used for allocation to new objects ?

EDIT : consider the scenerio : suppose Eden space is full and from survivor space occupancy is less, then in that case if new object is created (new object is small enough to fit into from survivor space) then will the minor collection occur or space for new object will be allocated from fromSurvivor space ?

+1  A: 

I believe eden space is always used for small objects, and very large objects are allocated directly in old space. If new objects were allocated in the survivor space, it would kinda defeat the point of having separate spaces.

See this PDF for more details, including:

Most objects are initially allocated in Eden. (As mentioned, a few large objects may be allocated directly in the old generation.)

Jon Skeet
suppose Eden space is full and from survivor space occupancy is less, then in that case if new object is created (new object is small enough to fit into from survivor space) then will the minor collection occur or space for new object will be allocated from fromSurvivor space ?
@user275131: I believe a minor collection will take place. Put it this way: I've seen nothing to suggest that's not the case.
Jon Skeet
@Skeet dont you think that if minor collection occur then we are going to waste the space from fromSurvivor or not utilizing it ?
@user275131: I suspect not, because it makes the normal allocation simpler and thus quite possibly quicker. The idea is that minor collections are *very* quick. I could be wrong about this, but I'm just going on the documentation. The performance of collectors is *really* complicated (bearing in mind multi-thread allocation) - I'm not really qualified to speak about it in detail, to be honest. If I *am* right about this, I'm sure they *considered* allocating directly into the "from" space.
Jon Skeet