Re: Delphi Dot Net, Better than Win32, or just Hype?
- From: Kevin <kevin@xxxxxxxxxxxxxxxxxxx>
- Date: Tue, 17 Jan 2006 12:25:54 -0600
Captain Jake wrote:
You can use reference-counted interfaces in Delphi Win32, which means the objects will be cleaned up when they are no longer referenced by any variable in an active scope. That makes it like a GC'ed environment, only better because it is deterministic and you can be assured of your destructor code being called.
Just one addition to this: Ref-counting isn't perfect. I believe Delphi's interfaces aren't immune to the COM circular refs problem.
If you have one "object" (object A) that references another "object" (object B) and that "object" references object A as well. Sure, that's often bad programming practice but it can happen and is sometimes even required. Some developers assume that everything will be cleaned up because it is reference counted. Just because you're using reference-counted types doesn't mean they'll always be cleaned up. You can still get memory leaks. So... garbage collection is at least better in this case: it will clean up the case where A references B, B references A and they've both been deallocated. Sure... it'll be non-deterministic but at least they'll eventually be cleaned up.
There are pros and cons to both. Neither GC nor ref-counting is better than one another. Sometimes creating and freeing objects is better. All have their drawbacks.
Cheers, Kevin. .
- References:
- Delphi Dot Net, Better than Win32, or just Hype?
- From: Steve Zimmelman
- Re: Delphi Dot Net, Better than Win32, or just Hype?
- From: Pete Goodwin
- Re: Delphi Dot Net, Better than Win32, or just Hype?
- From: Jeroen Vandezande
- Re: Delphi Dot Net, Better than Win32, or just Hype?
- From: Captain Jake
- Delphi Dot Net, Better than Win32, or just Hype?
- Prev by Date: Re: Delphi Dot Net, Better than Win32, or just Hype?
- Next by Date: Re: Live Templates "Library" on Wiki
- Previous by thread: Re: Delphi Dot Net, Better than Win32, or just Hype?
- Next by thread: Re: Delphi Dot Net, Better than Win32, or just Hype?
- Index(es):