[fpc-pascal] methods of an object to create others objects

Marcos Douglas md at delfire.net
Mon Jul 5 22:46:39 CEST 2010


On Mon, Jul 5, 2010 at 5:30 PM, Mattias Gaertner
<nc-gaertnma at netcologne.de> wrote:
>
> No. This will create a mem leak.

Thanks Mattias, I expect that...


On Mon, Jul 5, 2010 at 5:39 PM, Martin <fpc at mfriebe.de> wrote:
>
> 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.

Yes, as Mattias said too.

This type of construction should be banned, no?
Different this, some times I use OUT parameters to force the caller to
receive the result.


Marcos Douglas



More information about the fpc-pascal mailing list