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

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to