Re: arrays = pointers?
- From: "Zytan" <zytanlithium@xxxxxxxxx>
- Date: 2 Mar 2007 11:35:43 -0800
Sorry, I don't want to sound rude, but you got it wrong,
Telling me i'm wrong is not rude, so don't worry :)
each object reference is held in a
program variable, and this variable can actually exist in a register, on the stack, in the
Finalizer list or in the Handle table.
Ok.
N references can point to the same object in the GC heap, see sample [1].
Yes.
The JIT helps the GC, by updating a table (the GCInfo table) in which he stores the
aliveness state of the variables holding object references at JIT compile time (per method).
Ok.
Note that the JIT doesn't keep track of this for each machine instruction, only those that
can possibly trigger a GC are kept in the GCInfo table.
All the GC has to do is inspect the GCInfo table and start walking the stack(s) and the
handle table to find the references to dead objects and reset these references (set to
null). When done, he can start a compactation of the heap, hereby updating the life
references of the moved objects, in the stack and the handle table. Note that I've left-out
some details but at large that's it.
[1]
class C {
int i;}
...
void Foo()
{
C c = new C();
C c1 = c
(1)
...}
Here at point (1), the stack (or registers) will hold (at least) two reference to same
instance of C.
Yes.
Ok, while my explanation was very general, and as far as I can tell,
you explained the same thing, except in much more technical detail
(details that I didn't know). In general, this is what I suspected
was going on. Maybe I was unclear.
Thanks,
Zytan
.
- Follow-Ups:
- Re: arrays = pointers?
- From: Willy Denoyette [MVP]
- Re: arrays = pointers?
- References:
- Re: arrays = pointers?
- From: Peter Duniho
- Re: arrays = pointers?
- From: Göran Andersson
- Re: arrays = pointers?
- From: Zytan
- Re: arrays = pointers?
- From: Peter Duniho
- Re: arrays = pointers?
- From: Göran Andersson
- Re: arrays = pointers?
- From: Zytan
- Re: arrays = pointers?
- From: Willy Denoyette [MVP]
- Re: arrays = pointers?
- Prev by Date: Re: Does C# have static local variables like C++?
- Next by Date: Re: TypeInitializationException / forcing all static c'tors to run on startup
- Previous by thread: Re: arrays = pointers?
- Next by thread: Re: arrays = pointers?
- Index(es):
Relevant Pages
|