Re: Garbage collector and multiple threads
From: Stu Smith (stuarts_at_nospam-digita.com)
Date: 07/13/04
- Next message: localhost: "CLR Debug without Visual Studio?"
- Previous message: Larry Charlton: "Re: Page context"
- In reply to: David Browne: "Re: Garbage collector and multiple threads"
- Next in thread: Russell Hind: "Re: Garbage collector and multiple threads"
- Reply: Russell Hind: "Re: Garbage collector and multiple threads"
- Messages sorted by: [ date ] [ thread ]
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
>
>
- Next message: localhost: "CLR Debug without Visual Studio?"
- Previous message: Larry Charlton: "Re: Page context"
- In reply to: David Browne: "Re: Garbage collector and multiple threads"
- Next in thread: Russell Hind: "Re: Garbage collector and multiple threads"
- Reply: Russell Hind: "Re: Garbage collector and multiple threads"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|