On 05/07/2010 21:26, Marcos Douglas wrote:
If I have a variable myObj, I can do this:
someObj := myObj.createObj;

This is the same:
someObj := TsomeObject.create;

Rigth?

But if a remove the variable *someObj* and call like this:
myObj.createObj; // I _removed_ the *someObj* here!!!

What will happen with the "result" variable? Is it released by the compiler?


that is the same as if you wrote

  TsomeObject.create;

without assigning the created object to a variable. Both cause a memory leek.

Mind you just because "Create" is a constructor does not protect it from being called without using the result.

Martin

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

Reply via email to