<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Couple of things:<br>
<br>
Your test prog will not work since you had the logic slightly round the
wrong way, change the btnClick event to this:<br>
<br>
procedure TForm1.btnClick(Sender: TObject);<br>
begin<br>
&nbsp; if Started<br>
&nbsp; then begin<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; btn.Caption := 'Start';<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Started := False;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmr.Enabled := False;<br>
&nbsp; end<br>
&nbsp; else begin<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; btn.Caption := 'Pause';<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Started := True;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmr.Enabled := True;<br>
&nbsp; end;<br>
end;<br>
<br>
The way that you had it, the time never fires.<br>
<br>
The second thing is to use an interface to hold onto the object:<br>
<br>
procedure TForm1.tmrTimer(Sender: TObject);<br>
var<br>
&nbsp; lTest : IInterface;<br>
begin<br>
&nbsp; lTest := TTest.Create ('qwer');<br>
end;<br>
<br>
This causes the reference counting to work correctly and free the
created object as soon as the lTest variable goes out of scope.<br>
<br>
Rohit Gupta wrote:
<blockquote cite="mid427A3DE6.15038.1FAA9FB7@localhost" type="cite">
  <pre wrap="">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 <a class="moz-txt-link-rfc2396E" href="mailto:phil@tumonz.co.nz">&lt;phil@tumonz.co.nz&gt;</a>
Organization:           MTS Ltd
To:                     NZ Borland Developers Group - Delphi List <a class="moz-txt-link-rfc2396E" href="mailto:delphi@ns3.123.co.nz">&lt;delphi@ns3.123.co.nz&gt;</a>
Subject:                Re: [DUG] TInterfacedObject
Send reply to:          NZ Borland Developers Group - Delphi List <a class="moz-txt-link-rfc2396E" href="mailto:delphi@ns3.123.co.nz">&lt;delphi@ns3.123.co.nz&gt;</a>
        <a class="moz-txt-link-rfc2396E" href="mailto:delphi-request@ns3.123.co.nz?subject=unsubscribe">&lt;mailto:delphi-request@ns3.123.co.nz?subject=unsubscribe&gt;</a>
        <a class="moz-txt-link-rfc2396E" href="mailto:delphi-request@ns3.123.co.nz?subject=subscribe">&lt;mailto:delphi-request@ns3.123.co.nz?subject=subscribe&gt;</a>

[ 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:

  </pre>
  <blockquote type="cite">
    <pre wrap="">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" <a class="moz-txt-link-rfc2396E" href="mailto:rohit@cfl.co.nz">&lt;rohit@cfl.co.nz&gt;</a>
To: <a class="moz-txt-link-rfc2396E" href="mailto:rohit@cfl.co.nz">&lt;rohit@cfl.co.nz&gt;</a>; "NZ Borland Developers Group - Delphi List" 
<a class="moz-txt-link-rfc2396E" href="mailto:delphi@ns3.123.co.nz">&lt;delphi@ns3.123.co.nz&gt;</a>
Sent: Thursday, May 05, 2005 9:47 AM
Subject: [DUG] TInterfacedObject


    </pre>
    <blockquote type="cite">
      <pre wrap="">TInterfacedObject

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 <a class="moz-txt-link-abbreviated" href="mailto:rohit@cfl.co.nz">rohit@cfl.co.nz</a>  or  <a class="moz-txt-link-abbreviated" href="mailto:r.gupta@xtra.co.nz">r.gupta@xtra.co.nz</a>
====================================================
==================


_______________________________________________
Delphi mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a>
<a class="moz-txt-link-freetext" href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a>

      </pre>
    </blockquote>
    <pre wrap="">_______________________________________________
Delphi mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a>
<a class="moz-txt-link-freetext" href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a>



    </pre>
  </blockquote>
  <pre wrap=""><!---->
_______________________________________________
Delphi mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a>
<a class="moz-txt-link-freetext" href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a>
Regards

Rohit

======================================================================
CFL - Computer Fanatics Ltd.  21 Barry's Point Road, AKL, New Zealand
PH    (649) 489-2280 
FX    (649) 489-2290
email <a class="moz-txt-link-abbreviated" href="mailto:rohit@cfl.co.nz">rohit@cfl.co.nz</a>  or  <a class="moz-txt-link-abbreviated" href="mailto:r.gupta@xtra.co.nz">r.gupta@xtra.co.nz</a>
======================================================================




-------------- 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.

  </pre>
  <pre wrap="">_______________________________________________
Delphi mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a>
<a class="moz-txt-link-freetext" href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a>



  </pre>
</blockquote>
</body>
</html>