Archived Forum Post

Index of archived forum posts


Do I free "TprivateKey.Create(nil).ControlInterface;"??

Jan 23 '15 at 09:11

Using Chilkat RSA ActiveX with Delphi 2007. Pardon me, I know VCL pretty well. But when it comes to ActiveX controls not as versed.

I suspect my code has a memory leak. At least FastMM is pointing to it. I have signing function which creates a TPrivateKey:

    pkey := TprivateKey.Create(nil).ControlInterface;

But I am not freeing it ( gives compiler error).

Is this a memory leak? If so how do I get around it?

Accepted Answer

See the online Chilkat reference documentation for each Delphi ActiveX class:

You would call the Free method.

However, in your code snippet above, pkey is a COM interface, meaning it is an IPrivateKey and not a TPrivateKey. The "T" class is the OLE Control Proxy class. "Free" is a method of the "T" class.