[fpc-pascal] Memory leak in GetEnumerator

Xiangrong Fang xrfang at gmail.com
Fri Dec 27 10:16:16 CET 2013

Hi All,

I used HeapTrc on my TTreap class:


It reported memory leak in the following procedure:

function TTreap.GetEnumerator: TTreap;
  Result := TTreap.Create;  //<-- memory leak here
  Result.ProxyFor := Self;
  ... ...

Typical usage of the TTreap enumerator is:

 for n in aTreap do begin
   //do something with n

My question is: will the for-loop automatically free the enumerator after
usage?  How to fix leaks in my ttreap class?

Thanks a lot!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20131227/9f3d3866/attachment.html>

More information about the fpc-pascal mailing list