T
Tony Johansson
Hello!
I have read in a book that garbage collector(GC) is allowed to (and needs)
to move objects
in order to defragment the heap.
One thing that I wonder is what happen with those objects that I still have
a reference to and is using ?
This statement will not compile(in unsafe section)
int* pa = new int[5];
in a program because of the following that I don't understand
"What would happen if the garbage collector decide to move the object and we
were pointing to it and using it"
When having these kind of statement
int* pa = new int[5];
You I have to use a fixed keyword like this
(fixed) {int* pa = new int[5];}
I can't understand why the keyword fixed need to be used ?
I mean I don't use pointer but I use object that is located on the heap all
the time and those object is moved around by the GC and that works fine. So
why is it nesessary to use this keywork fixed when having statement like
this
int* pa = new int[5];
//Tony
I have read in a book that garbage collector(GC) is allowed to (and needs)
to move objects
in order to defragment the heap.
One thing that I wonder is what happen with those objects that I still have
a reference to and is using ?
This statement will not compile(in unsafe section)
int* pa = new int[5];
in a program because of the following that I don't understand
"What would happen if the garbage collector decide to move the object and we
were pointing to it and using it"
When having these kind of statement
int* pa = new int[5];
You I have to use a fixed keyword like this
(fixed) {int* pa = new int[5];}
I can't understand why the keyword fixed need to be used ?
I mean I don't use pointer but I use object that is located on the heap all
the time and those object is moved around by the GC and that works fine. So
why is it nesessary to use this keywork fixed when having statement like
this
int* pa = new int[5];
//Tony