std.container.Array/RefCounted(T) leaking memory?

Jesse Phillips jessekphillips+D at gmail.com
Thu Jan 13 09:40:04 PST 2011


Steven Schveighoffer Wrote:

> But even so, malloc and free have the same property where they don't  
> always give back memory to the OS.  IIUC, Linux can only change the size  
> of memory it wants, it cannot free pages in the middle of the block.
> 
> -Steve

Disclaimer: I don't know what I am talking about.

I think this is correct, the program isn't responsible for reclaiming the memory, that is what the OS does. If you don't have an OS then you don't have anything to return the memory to, so it just becomes free memory. Modern operating systems aren't going to take their memory back until it is needed (wast of cycles).

What I observed using Linux and $ free; each section would result in a reduction of free memory and an increase in buffered data. This suggests to me that the OS doesn't want the memory yet.

Tracking memory in a modern OS is not easy, and this is probably why no one wanted to make a statement on what was really happening. As I said I don't know if this is what is happening, but it usually isn't as straight forward as checking memory usage.


More information about the Digitalmars-d-learn mailing list