[fpc-pascal] Memory leak or object destruction?
Bo Berglund
bo.berglund at gmail.com
Thu Feb 3 00:22:42 CET 2011
I am curious as to how FPC handles the following situations:
var
MyObj: TsomeObject;
begin
MyObj := TsomeObject.Create;
// do some processing
MyObj := NIL;
end;
Will this create a memory leak or will FPC fnd by reference counting
that nothing references the object memory and dispose of it?
If the latter, will the disposal call the object's destructor or not?
next:
var
MyObj: TsomeObject;
begin
MyObj := TsomeObject.Create;
// do some processing
end;
What happens here where the local variable MyObj gets out of scope,
again with the reference to object memory disappearing?
Memory leak or object destruction?
--
Bo Berglund
Developer in Sweden
More information about the fpc-pascal
mailing list