Hi All,

I used HeapTrc on my TTreap class:

https://github.com/xrfang/fpcollection/blob/master/src/units/treap.pas

It reported memory leak in the following procedure:


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

Typical usage of the TTreap enumerator is:

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

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

Thanks a lot!

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

Reply via email to