|
Couple of things: Your test prog will not work since you had the logic slightly round the wrong way, change the btnClick event to this: procedure TForm1.btnClick(Sender: TObject); begin if Started then begin btn.Caption := 'Start'; Started := False; tmr.Enabled := False; end else begin btn.Caption := 'Pause'; Started := True; tmr.Enabled := True; end; end; The way that you had it, the time never fires. The second thing is to use an interface to hold onto the object: procedure TForm1.tmrTimer(Sender: TObject); var lTest : IInterface; begin lTest := TTest.Create ('qwer'); end; This causes the reference counting to work correctly and free the created object as soon as the lTest variable goes out of scope. Rohit Gupta wrote: Phil, it doesnt work for me. Here is the test app. Destructor is never called. Not even the BeforeDestruction of TInterfacedObject is not called. I have tried to make the loop elaborate to ensure that the linker is not being too smart... but no go.What am I missing ? Date sent: Thu, 05 May 2005 10:50:34 +1200 From: Phil Middlemiss <[EMAIL PROTECTED]> Organization: MTS Ltd To: NZ Borland Developers Group - Delphi List <[email protected]> Subject: Re: [DUG] TInterfacedObject Send reply to: NZ Borland Developers Group - Delphi List <[email protected]> <mailto:[EMAIL PROTECTED]> <mailto:[EMAIL PROTECTED]> [ Double-click this line for list subscription options ] You could put a break point in the destructor for the TInterfacedObject descendant and if it doesn't get called (which it sounds like it's not) then you know that you still have something, somewhere, referencing it. Cheers, Phil. Dennis Chuah wrote:Works for me all the time. The object sis freed when the reference count reaches 0. Check for circular references. The number of handles in task manager is all handles, process, thread, file, duplicate, etc. that are opened/created by the process. ----- Original Message ----- From: "Rohit Gupta" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>; "NZ Borland Developers Group - Delphi List" <[email protected]> Sent: Thursday, May 05, 2005 9:47 AM Subject: [DUG] TInterfacedObjectTInterfacedObject Am I right in concluding that any descendant will be reference counted and the memory released automatically ? I an a particular very small app, this doesnt appear to be the case. Every time it handles a transaction the memory goes up by 60K and the handle count by 8. Next question, what is this handle count in the task manager ? Is it file handles, process handles ???? Regards Rohit ==================================================== ================== CFL - Computer Fanatics Ltd. 21 Barry's Point Road, AKL, New Zealand PH (649) 489-2280 FX (649) 489-2290 email [EMAIL PROTECTED] or [EMAIL PROTECTED] ==================================================== ================== _______________________________________________ Delphi mailing list [email protected] http://ns3.123.co.nz/mailman/listinfo/delphi_______________________________________________ Delphi mailing list [email protected] http://ns3.123.co.nz/mailman/listinfo/delphi_______________________________________________ Delphi mailing list [email protected] http://ns3.123.co.nz/mailman/listinfo/delphi Regards Rohit ====================================================================== CFL - Computer Fanatics Ltd. 21 Barry's Point Road, AKL, New Zealand PH (649) 489-2280 FX (649) 489-2290 email [EMAIL PROTECTED] or [EMAIL PROTECTED] ====================================================================== -------------- Enclosure number 1 ---------------- * This message contains the file 'proj.ZIP', which has been * uuencoded. If you are using Pegasus Mail, then you can use * the browser's eXtract function to lift the original contents * out to a file, otherwise you will have to extract the message * and uudecode it manually._______________________________________________ Delphi mailing list [email protected] http://ns3.123.co.nz/mailman/listinfo/delphi |
_______________________________________________ Delphi mailing list [email protected] http://ns3.123.co.nz/mailman/listinfo/delphi
