On Tue, 23 Feb 2010 09:34:19 -0500, bearophile <[email protected]> wrote:

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.

I don't know if this is possible. D would have to replace C's malloc in order to do this, but I don't think that's a good idea. Also, however, C's malloc isn't as likely to explode memory usage because items should be freed when they are no longer used. GC-based languages tend to use more memory because there are at any one time a lot of unused pieces of memory waiting to be cleaned.

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.

It is a risk, but it is entirely dependent on factors outside the program's control. For example, how much memory is available. If you limit to 200MB, what if you have to run 50 programs that were built from D with the same default limit, that's 10GB limit. I just don't think it's realistic to come up with a simple per-program limit that solves the problem.

- 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).

Again, this can be done in the GC code itself, it does not need to be a compiler-defined limit. My preference is for the default to be unlimited, since this is the most common case.

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.

This isn't a common case though. An artificial limit that has no consideration of available memory seems like it would lead to more puzzlement than help.

-Steve

Reply via email to