[fpc-pascal] Disposing pointers and memory leaks

Joseph Montanez jmontanez at gorilla3d.com
Sun Mar 29 18:01:45 CEST 2009


Paul,

No wonder i had memory that kept growning. Thank you soo much!

On Sun, Mar 29, 2009 at 2:14 AM, Paul Ishenin <webpirat at mail.ru> wrote:
> Joseph Montanez wrote:
>>
>>      New(Cursor);
>>
>
> You allocated memory for Cursor
>>
>>      Cursor := DrawPixel(Screen, X, Y, 253, 253, 253);
>>
>
> You assigned something to Cursor. Thus it is not pointed anymore to your
> previously allocated memory.
>>
>>      Dispose(Cursor);
>>
>
> You are trying to deallocate memory to which Cursor is pointing. Don't
> forget that it is pointing to the memory allocated by New anymore after that
> assignment.
>
> I suppose you need to remove both New and Dispose.
>
> Best regards,
> Paul Ishenin.
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>



More information about the fpc-pascal mailing list