On 5 July 2010 22:03, Marcos Douglas wrote:
> The ask is:
> If a function creates, inside, a object and there is no variable to
> receive this pointer, will happen a memory leak?

Yes you will have a memory leak. Easy way to test is to enable the
heaptrc unit (compiler option -gh). On terminating the application,
the heaptrc unit will dump memory usage output to the console window.

If the object returned is a reference counted object, then I think it
will be freed (though not working with the interface instance itself
is bad practice).

Remember FPC doesn't have garbage collection like Java or .NET.  Rule
of thumb is that if you created it, you need to free it.


-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
_______________________________________________
fpc-pascal maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to