Heap memory limit?

bearophile bearophileHUGS at lycos.com
Tue Feb 23 06:34:19 PST 2010


Steven Schveighoffer:

> The GC is open source.  Submit a patch if you want.

It can be nice if the the C heap too is counted in such max memory used. I don't know if this is possible.


>DMD is not in charge of the GC, it is runtime code, I don't think we need a specific option for it.<

- D2 code has safe modules too, they are meant to turn D code into something a little safer than usual C code.
- I think using too much memory is a unsafe situation, a small risk. You are free to not agree.
- If it's seen as a real small risk, then if you want to do something concrete to avoid this risk, you need such memory limit enforced by default (if it's not a default, very few people will use it, and this small risk will be often ignored). And it can be positive if all D implementations share have this safety. That's why I was talking about a compiler argument (plus eventually a small program to change at runtime the limit of an already compiled program. Another silly possible solution is to use  small program to modify the max value contained into the binary itself, a kind of binary patching).
- If you want the original behaviour you can compile with something like:
dmd -mlimit=none foo.d
This disables such limiting (it disables the run-time tests too, so the allocations become a bit faster too).


> I also don't think that limits to memory are too important for most  
> applications, only for specific ones.

It's not just my desire to copy Java, I have made my PC unstable few times because a bug in my code has caused a D proggy to eat too much memory, so having a default limit of memory used seems useful to me.

Bye,
bearophile



More information about the Digitalmars-d mailing list