Re: Is this correct? (TADOConnection)




<danielk1@xxxxxxxxx> escreveu na mensagem
news:1161379473.609229.42860@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Not sure what you are asking, the code is from the unit ADODB. Are you
wondering if your connection/object is free at this point?

Precisely.... Notice that connection object is created in the constructor in
CreateADOObject() function - wich calls CoCreateInstance with the proper
CLSID.
CoCreateInstance will call AddRef() IUnknown's member, but at the destructor
FConnectionObject is simply set to nil without calling Release()!

This means any connection object will remain in memory until the processes
dies... or am I wrong?

[]s
Fred


Frederico Pissarra wrote:
Hello!!!

Taking a look at ADODB unit in $(DELPHI)\Source\VCL (I'm using D7 here),
you
can see the following code:

-------------%<------------cut
here -------------%<------------------------
destructor TADOConnection.Destroy;
begin
Destroying;
Close;
ClearRefs;
FreeAndNil(FCommands);
if FConnEventsID > 0 then
OleCheck(ConnectionPoint.UnAdvise(FConnEventsID));
FConnEventsID := 0;
FConnectionObject := nil;
inherited Destroy;
end;

-------------%<------------cut
here -------------%<------------------------

Notice that FConnectionObject is not released (calling IUnknown.Release),
but the reference simply will point to nil.

Is this correct?

[]s
Fred


.