Re: Garbage collector and multiple threads

From: Stu Smith (stuarts_at_nospam-digita.com)
Date: 07/13/04


Date: Tue, 13 Jul 2004 17:41:20 +0100


"David Browne" <davidbaxterbrowne no potted meat@hotmail.com> wrote in
message news:O1cCL25YEHA.396@TK2MSFTNGP10.phx.gbl...
>
> "Pawan Singh" <k2k2e6@yahoo.com> wrote in message
> news:ODZF0r4YEHA.728@TK2MSFTNGP09.phx.gbl...
> > Unfortunately, the project has to be done in .Net. That is why I wanted
to
> > suspend GC for short duration. I do not want to stop it completely - I
> want
> > it not to run for some controlled time or "spare my thread and its
> objects"
> > when it wants to run. That would solve my problem.
> >
>
> The only way to prevent Garbage Collection is to create no garbage.
Garbage
> Collection is always triggered by a request to allocate an object on the
> managed heap. If your application gets to a state where it creates no
> additional heap objects, then no Garbage Collections will occur.
>
> While not imposible, achieving this is quite tricky and requires you to
> closely control object creation and allocation in the whole process in
ways
> which severly constrain your programming. For instance you must replace
> reference objects with value objects, recycle reference objects instead of
> allocating new ones, and refrain from invoking any .net framework methods
> without verifing that they don't create temporary heap objects (which is
> never documented, and never guaranteed not to change).
>
> In short, your program would be so contorted by the no-garbage requirement
> that you would be better off writing in unmanaged C++.

Do AppDomains have separate heaps, and so separate garbage collectors? If
so, you could potentially do your minimal allocation stuff in a separate
domain.

Even if that is the case, I'd still agree that .NET probably isn't the best
platform for real-time programming. Might we ask why the project must be
done in .NET? Why can't it be mixed mode?

>
> The only other thing I can think of is that if you allocate little enough
> heap memory, you might get your GC times down to short enough not to care
> when GC runs. Add to that manual GC.Collect() when you know you have
time,
> and you might squeak by.
>
> David
>
>



Relevant Pages

  • Re: P-Source: A Guide to the Apple Pascal System
    ... Activation frames will be allocated from these chunks until it is ... then allocate another chunk and link to it. ... allocated dynamically, managed like anything else in the heap, and even ... I will have a background thread that runs garbage collection and calls ...
    (comp.sys.apple2)
  • Re: P-Source: A Guide to the Apple Pascal System
    ... then allocate another chunk and link to it. ... allocated dynamically, managed like anything else in the heap, and even ... I will have a background thread that runs garbage collection and calls ... Threading should have close to zero impact on performance. ...
    (comp.sys.apple2)
  • Re: P-Source: A Guide to the Apple Pascal System
    ... then allocate another chunk and link to it. ... allocated dynamically, managed like anything else in the heap, and even ... I will have a background thread that runs garbage collection and calls ... Threading should have close to zero impact on performance. ...
    (comp.sys.apple2)
  • Re: Huge pages and small pages. . .
    ... >> what looks like contiguous memory and away you go. ... you need to have them cached in the TLB; if the TLB runs out of ... > low end of the heap, until someone figures out a way to tell the system ... When you allocate memory, the kernel just marks a promised ...
    (Linux-Kernel)
  • Re: Struct inside class
    ... The compiler figures computes the ... including anything derived from "Object": Heap pointer ... memory leaks and why the .NET good garbage collector is required. ... If GC_ALLOCATE can't allocate the requested ...
    (microsoft.public.dotnet.framework)