std.container.Array/RefCounted(T) leaking memory?
Jesse Phillips
jessekphillips+D at gmail.com
Thu Jan 13 14:25:19 PST 2011
Thanks very nice info, just two guys babbling about things they've only read I guess, but you seem much better informed.
Steven Schveighoffer Wrote:
> I think all memory is allocated/deallocated from the OS via the sbrk/brk
> system call:
>
>
> brk() and sbrk() change the location of the program break,
> which
> defines the end of the process's data segment (i.e., the program
> break
> is the first location after the end of the uninitialized data
> segment).
> Increasing the program break has the effect of allocating memory to
> the
> process; decreasing the break deallocates memory.
>
> So you can only ever add to the *end* of memory, and you can only ever
> deallocate from the *end*. And the OS doesn't ever just jump in and claim
> memory, you have to tell it that you are deallocating memory.
>
> Which means, if you say allocated 100MB, and wanted to deallocate the
> first 99MB, you still couldn't release any back to the OS.
>
> A moving GC would allow for more memory to be freed, but we aren't there
> yet.
>
> Of course, I could be completely wrong about all this, I've never really
> used sbrk or brk :)
>
> -Steve
More information about the Digitalmars-d-learn
mailing list