Home All Groups Group Topic Archive Search About

CLR behavior about accessing data during garbage collection working

Author
10 Nov 2006 4:41 PM
Hyun-jik Bae
I got a curiosity while using CLR.
How can it be done that accessing object data by CLR application is safe
even while garbage collector is working? Is the GC thread running in
realtime priority for this for example?
Please reply. Thanks in advance.

Hyun-jik Bae

Author
10 Nov 2006 5:18 PM
Ciaran O''Donnell
The CLR pauses all threads while garbage collecting. Thats why it is a
performance hit to call it yourself and to keep invoking it with short term
memory allocations.

Ciaran O'Donnell

Show quote
"Hyun-jik Bae" wrote:

> I got a curiosity while using CLR.
> How can it be done that accessing object data by CLR application is safe
> even while garbage collector is working? Is the GC thread running in
> realtime priority for this for example?
> Please reply. Thanks in advance.
>
> Hyun-jik Bae
>
>
>
>
Author
10 Nov 2006 6:17 PM
Michael Nemtsev
Hello Hyun-jik Bae,

Just to add Ciaran's post:
GC pause nothing, it just ask CLR to suspend/resume threads.
It's not just simple suspension, there are some cases how threads are suspended
based on whether threads are in managed code or not

H> I got a curiosity while using CLR.
H> How can it be done that accessing object data by CLR application is
H> safe
H> even while garbage collector is working? Is the GC thread running in
H> realtime priority for this for example?
H> Please reply. Thanks in advance.
H> Hyun-jik Bae
H>
---
WBR,
Michael  Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Author
28 Nov 2006 12:26 AM
Gabriel Lozano-Morán
I always thought that the GC will not collect managed resources when they
are in use and that's exactly what he is saying no? Unmanaged resources
that's a different story that's why we have GC.KeepAlive()

Gabriel Lozano-Morán

Show quote
"Michael Nemtsev" <nemt***@msn.com> wrote in message
news:1799a79b3bd2168c8d324cfb930c7@msnews.microsoft.com...
> Hello Hyun-jik Bae,
>
> Just to add Ciaran's post:
> GC pause nothing, it just ask CLR to suspend/resume threads. It's not just
> simple suspension, there are some cases how threads are suspended based on
> whether threads are in managed code or not
>
> H> I got a curiosity while using CLR.
> H> How can it be done that accessing object data by CLR application is
> H> safe
> H> even while garbage collector is working? Is the GC thread running in
> H> realtime priority for this for example?
> H> Please reply. Thanks in advance.
> H> Hyun-jik Bae
> H> ---
> WBR,
> Michael  Nemtsev :: blog: http://spaces.live.com/laflour
>
> "At times one remains faithful to a cause only because its opponents do
> not cease to be insipid." (c) Friedrich Nietzsche
>
>
Author
5 Dec 2006 10:56 PM
Ben Voigt
"Hyun-jik Bae" <imays_NOSPAM@hitel.net> wrote in message
news:ev54sbOBHHA.4592@TK2MSFTNGP03.phx.gbl...
>I got a curiosity while using CLR.
> How can it be done that accessing object data by CLR application is safe
> even while garbage collector is working? Is the GC thread running in

It isn't.... the gc moves everything.  That's why the GC suspends all
threads in managed code before it starts running.

Show quote
> realtime priority for this for example?
> Please reply. Thanks in advance.
>
> Hyun-jik Bae
>
>
>
Author
6 Dec 2006 6:32 AM
Michael Nemtsev
Hello Ben,

A small addition - GC calls functions to do the suspension and the resumption
as a service provided in the CLR.
It's the work of CLR and EE(Execution Engine) to manage this

BV> "Hyun-jik Bae" <imays_NOSPAM@hitel.net> wrote in message
BV> news:ev54sbOBHHA.4592@TK2MSFTNGP03.phx.gbl...
BV>
>> I got a curiosity while using CLR.
>> How can it be done that accessing object data by CLR application is
>> safe
>> even while garbage collector is working? Is the GC thread running in
BV> It isn't.... the gc moves everything.  That's why the GC suspends
BV> all threads in managed code before it starts running.
BV>
>> realtime priority for this for example?
>> Please reply. Thanks in advance.
>> Hyun-jik Bae
>>
---
WBR,
Michael  Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche

AddThis Social Bookmark Button