Any way to track memory allocations?

Daniel Keep daniel.keep.lists at gmail.com
Tue Feb 24 17:23:59 PST 2009



wade wrote:
> Thanks again for all the help.  I found what the problem was and it wasn't obvious (at least to me):
> 
> float[uint] arr;
> 
> foreach (uint k; arr.keys)
> {
>  ...
> }
> 
> Changing this to:
> 
> foreach (uint k, float v; arr)
> {
> ....
> }
> 
> fixes the leak.  I guess the keys array is constructed on the fly?
> 
> wade

Yup.

It's a pity that we don't have, oh I don't know, some sort of efficient
iterable interface that doesn't cause a heap allocation that the runtime
could use instead *cough*hint*cough*andrei*cough*ranges*cough*.

  -- Daniel


More information about the Digitalmars-d-learn mailing list