Re: GC.Collect can be trusted?
- From: "Christof Nordiek" <cn@xxxxxxxxx>
- Date: Thu, 19 Apr 2007 16:24:04 +0200
"Christopher Ireland" <cireland@xxxxxxxxx> schrieb im Newsbeitrag
news:3B8B5DE7-7F87-4A76-AEFA-83089A363450@xxxxxxxxxxxxxxxx
"Because of the garbage collection package that is implemented in the
Microsoft .NET Framework, it is not possible to have a memory leak in
managed code. This suggests two questions: How then can a memory leak
occur? Why does it appear that you have a memory leak?"
Though garbage collection is very usefull to provent memory leaks, this
quote is a bit to optimistic. Sure ther can be memory leaks in managed code.
E.g. all static fields aren't collected. So any object directly or
indirectly referenced by a static field wouldn't be collected. Also any
variables very high in the call stack can prevent referenced object from
being collected, (though the lifetime of a variable can be shortened by the
compiler.)
By this a memory leak in managed code can easily construckted.
But it's very unlikely to happen in real code. And it's much 'harder' to do
it purposelessly in managed code, than in unmanaged colde.
Regards
Christof
.
- Follow-Ups:
- Re: GC.Collect can be trusted?
- From: Christopher Ireland
- Re: GC.Collect can be trusted?
- References:
- GC.Collect can be trusted?
- From: Ward Bekker
- Re: GC.Collect can be trusted?
- From: Christopher Ireland
- GC.Collect can be trusted?
- Prev by Date: RichTextBox - Show Unicode Control Characters
- Next by Date: Re: how to invoke event
- Previous by thread: Re: GC.Collect can be trusted?
- Next by thread: Re: GC.Collect can be trusted?
- Index(es):
Relevant Pages
|