Click here to Skip to main content
15,905,148 members
Home / Discussions / C#
   

C#

 
GeneralRe: Finalizer implementation Pin
George_George23-Apr-08 2:49
George_George23-Apr-08 2:49 
Generalroot in managed heap Pin
George_George19-Apr-08 21:01
George_George19-Apr-08 21:01 
GeneralRe: root in managed heap Pin
Gareth H19-Apr-08 23:15
Gareth H19-Apr-08 23:15 
GeneralRe: root in managed heap Pin
George_George19-Apr-08 23:21
George_George19-Apr-08 23:21 
GeneralRe: root in managed heap Pin
Jordanwb20-Apr-08 4:06
Jordanwb20-Apr-08 4:06 
GeneralRe: root in managed heap Pin
Luc Pattyn20-Apr-08 2:37
sitebuilderLuc Pattyn20-Apr-08 2:37 
GeneralRe: root in managed heap Pin
George_George20-Apr-08 3:16
George_George20-Apr-08 3:16 
GeneralRe: root in managed heap Pin
Luc Pattyn20-Apr-08 3:38
sitebuilderLuc Pattyn20-Apr-08 3:38 
Hi George,

1.
I was inaccurate for the heap; most systems use a variation of this scheme:
- stop all threads;
- walk the heap ONLY to mark all objects as dead;
- then perform the algorithm based on the thread stacks (and CPU registers),
marking the live objects as not-dead (see below);
- resume all threads;
- walk the heap to delete all objects that are still marked dead.
There are different schemes (e.g. for better real-time behavior, not really a Windows thing),
for better performance (with generations, implemented in MS .NET), etc. Some are completely
different (e.g. based on reference counts, which is very hard to get right
in cyclic situations). The last step (delete) can be delegated to another (low-prio)
thread.

2.
stack is easy: for each new thread the stack pointer is initialized to some value ("stack
base") and every time something gets pushed onto the stack, the pointer moves away from
that base (either up or down, depends on the CPU architecture).
So the GC will search the stack from its current position towards the stack base,
and threat every 4 or 8 bytes as a potential reference. If it falls outside the heaps,
if is definitely not a reference, hence it gets skipped. If it falls inside the range
of one of the heaps, some extra fields are checked, and if they match it is considered
an object, hence marked alive.


Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.


GeneralRe: root in managed heap Pin
George_George20-Apr-08 4:42
George_George20-Apr-08 4:42 
GeneralRe: root in managed heap Pin
Luc Pattyn20-Apr-08 13:03
sitebuilderLuc Pattyn20-Apr-08 13:03 
GeneralRe: root in managed heap Pin
George_George20-Apr-08 19:20
George_George20-Apr-08 19:20 
GeneralRe: root in managed heap Pin
Luc Pattyn20-Apr-08 22:42
sitebuilderLuc Pattyn20-Apr-08 22:42 
GeneralRe: root in managed heap Pin
George_George20-Apr-08 23:46
George_George20-Apr-08 23:46 
GeneralRe: root in managed heap Pin
Luc Pattyn21-Apr-08 0:32
sitebuilderLuc Pattyn21-Apr-08 0:32 
GeneralRe: root in managed heap Pin
George_George21-Apr-08 1:08
George_George21-Apr-08 1:08 
GeneralRe: root in managed heap Pin
Luc Pattyn21-Apr-08 1:23
sitebuilderLuc Pattyn21-Apr-08 1:23 
GeneralRe: root in managed heap Pin
George_George21-Apr-08 2:04
George_George21-Apr-08 2:04 
GeneralRe: root in managed heap Pin
Luc Pattyn21-Apr-08 4:00
sitebuilderLuc Pattyn21-Apr-08 4:00 
GeneralRe: root in managed heap Pin
George_George21-Apr-08 4:16
George_George21-Apr-08 4:16 
GeneralFileStream.Read(); Pin
Ian Uy19-Apr-08 18:33
Ian Uy19-Apr-08 18:33 
GeneralRe: FileStream.Read(); Pin
Zoltan Balazs20-Apr-08 0:11
Zoltan Balazs20-Apr-08 0:11 
GeneralRe: FileStream.Read(); Pin
Ian Uy20-Apr-08 1:14
Ian Uy20-Apr-08 1:14 
GeneralComboBox not properly adding items Pin
Jordanwb19-Apr-08 14:10
Jordanwb19-Apr-08 14:10 
GeneralRe: ComboBox not properly adding items Pin
Luc Pattyn19-Apr-08 15:12
sitebuilderLuc Pattyn19-Apr-08 15:12 
GeneralRe: ComboBox not properly adding items Pin
Jordanwb19-Apr-08 15:53
Jordanwb19-Apr-08 15:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.