Memory leak issues TROBinaryMemoryStream


(hsvandrew) #1

Hi guys, I clearly don’t understand how delphi works (XE4) can you explain something

Using RemObjects 7.0.69

procedure TROBinMessage.Initialize(const aTransport: IROTransport; const anInterfaceName, aMessageName: string; aType: TMessageType);
var
http: IROHTTPTransportEx;
begin
inherited;

SetHTTPInfo(aTransport, DataFormatBinary);

if fDestroyStream then FreeAndNIL(fStream);
fStream := GetStreamClass.Create;
iSystemLog.logMessage( 'fStream[1] = ’ + inttostr(integer(fStream)) );
iSystemLog.logMessage( 'fStream[1] = ’ + GetStreamClass.ClassName );
iSystemLog.logMessage( 'fStream[1] = ’ + fStream.className );
fDestroyStream := TRUE;

constructor TROBinaryMemoryStream.Create;
begin
inherited Create;
iSystemLog.LogMessage( 'TROBinaryMemoryStream.Create ’ + inttostr(integer(self)) );
System_MemoryManager.leakDetect[className].inc;
end;

The output is as follows

[MAC] 04:42:13 AM - fStream[1] = -1773221376
[MAC] 04:42:13 AM - fStream[1] = TROBinaryMemoryStream
[MAC] 04:42:13 AM - fStream[1] = TROBinaryMemoryStream
[MAC] 04:42:13 AM - TROBinaryMemoryStream.Create -1773220160
[MAC] 04:42:13 AM - Instance Count of trobinarymemorystream is 1
[MAC] 04:42:13 AM - Instance Count of trobinarymemorystream is 0
[MAC] 04:42:13 AM - TROBinaryMemoryStream.destroy -1773220160
[MAC] 04:42:13 AM - fStream[IntReadFromStream] = -1773221376
[MAC] 04:42:13 AM - aStream[IntReadFromStream] = -1773220224
[MAC] 04:42:13 AM - Instance Count of trobinarymemorystream is -1

This seems dangerous as the constructor was never created. You probably don’t notice because nothing actually happens in the constructor, but I want to understand is this expected/normal?


(hsvandrew) #2

I meant ‘constructor was never called’


(hsvandrew) #3

Ignore this issue although I find the description scary

How is it not a bug that an object can be created without its constructor being called!!