Heap memory limit?

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Tue Feb 23 05:44:15 PST 2010


bearophile wrote:
> The Java VM has a limit of the amount of memory it allocates from the heap. So is it useful to add a way to specify a similar limit for D2 programs (especially ones made by safe module)? This limit can be given to the D GC heap (and maybe to the C heap too).
> 
> This limit can just be a compile-time constant given to the compiler, this produces a binary that has a limit of 200 MB of heap:
> dmd -mlimit=200mb foo.d
> The situation gets less simple if you want to change such limit after the program is already compiled, I don't know of simple ways to do it. Maybe a second program can be used for that:
> gclimiter -mlimit=100mb foo.exe

On Linux you can use the shell's built-in 'ulimit' command to set such a 
limit:

$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 20
file size               (blocks, -f) unlimited
pending signals                 (-i) 16382
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) unlimited
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited


-Lars



More information about the Digitalmars-d mailing list