[dmd-internals] DMD internal memory management issue

Walter Bright walter at digitalmars.com
Wed Dec 9 02:08:24 PST 2009


What can I say? These all need to be fixed. Thanks for helping identify 
them.

Denis wrote:
>
>
> That's the most obvious case. Unfortunately, there are cases that are
> harder to track and fix.
> For example, OutBuffer uses mem.malloc/mem.realloc and result is
> sometimes assigned to elem*, Symbol* and block* variables (and freed
> by backend).
> A string, created in FileName::forceExt (it evaluates return new
> FileName(s, 0); which does mem.strdup in String ctor) is also
> deallocated in backend.
> el_setLoc does raw pointer assignment. Who knows how original string
> was allocated? Deallocated in backend.
>
> You could probably catch all the occurrences saving all the allocated
> pinters in a map and checking that the pointer to deallocate is indeed
> present in that map. MEM_DEBUG already half of the needed
> functionality. Fortunately, all the backend allocations/deallocation
> are forwarded to tk/mem.c (at least the problematic ones).
>
>   


More information about the dmd-internals mailing list