Re: About speed
- From: Robert Giesecke <Spam@xxxxxxxxx>
- Date: Sun, 25 Jun 2006 13:10:55 +0200
Ingvar Nilsen wrote:
In fact, using "using" requires the object in question to support
IDisposable.
I am wondering if the system at all calls Dispose()? Does the GB call
Dispose()? Most likely.. Easy to test, shall I?
Most IDisposables have a finalizer, that will call Dispose when the object is marked on a GC sweep. But those IDisposables will most likely call GC.SupressFinalizer inside their Dispose method. Thus using "using" will prevent finalizers from being executed. Finalizers can slow things extremely down, because they to be synchronized as the GC runs in its own thread.
>
> And you are right. There is no way to free objects the Delphi way as
> far as I know.
>
It is possible, but I won't explain how. Last time I did, I had to explain that someone why he shoot himself in the foot. You only need it, if your design is fundamentally flawed. But then, you'd have to redesign anyway. ;-)
A not-as-nasty-but-still-flawed solution would be to call GC.Collect twice. Thus every non-collected object will be gen 1 after the first collect and since it wasn't touched between the 1st and the 2nd, it will be free'd after the 2nd Collect.
This *could* be necessary if you won't leave enough resources for the GC Thread to do its job. In a standard user-mode application, GC will run in a Background thread. Thus if you do a lot of crunching, GC will sweep only if you've eaten *lots* of memory.
.
- Follow-Ups:
- Re: About speed
- From: Barry Kelly
- Re: About speed
- From: Ingvar Nilsen
- Re: About speed
- References:
- About speed
- From: alavna
- Re: About speed
- From: Árpád Soós
- Re: About speed
- From: Oliver Townshend
- Re: About speed
- From: Don Strenczewilk
- Re: About speed
- From: Bryce K. Nielsen
- Re: About speed
- From: Craig Stuntz [TeamB]
- Re: About speed
- From: Bryce K. Nielsen
- Re: About speed
- From: Ingvar Nilsen
- Re: About speed
- From: Bryce K. Nielsen
- Re: About speed
- From: Ingvar Nilsen
- Re: About speed
- From: Bryce K. Nielsen
- Re: About speed
- From: Joanna Carter [TeamB]
- Re: About speed
- From: Ingvar Nilsen
- About speed
- Prev by Date: Re: Delphi in more schools (was Re: Microsoft here I come)
- Next by Date: Re: About speed
- Previous by thread: Re: About speed
- Next by thread: Re: About speed
- Index(es):
Relevant Pages
|