3
votes
Vote UpVote

On the reference counting bugs in Delphi

The Programming Works – Delphi allows to access an object instance via object reference and interface reference at the same time. Consider this code: program RefCounts; {$APPTYPE CONSOLE} uses SysUtils; procedure Test; var Obj: TInterfacedObject; II: IInterface; begin Obj:= TInterfacedObject.Create; Writeln(Obj.RefCount); // 0 II:= Obj; Writeln(Obj.RefCount); // 1 II:= nil; // here Obj is already destroyed and we can't reference it anymore // Writeln(Obj.RefCount); end; begin Test; Readln; end. Nasty thing is that a reference-counted object is created with zero ...
Favorite? Off-Topic? Serg @ 2013-08-14 07:15

Statistics

Visits: 1139
Votes: 3
Favorites: 0
Off-Topic: 0

Visits by Source

User Actions

Users who voted for this posting

Alister Christie
Neonimous
NickHodges
Subscribe:
Contact us to advertise on DelphiFeeds.com

Community Links

Torry Firebird News

Sponsor

 
Please login or register to use this functionality.
(click on this box to dismiss)