2 Replies Latest reply: Aug 31, 2011 9:28 PM by D7
D7 Level 2 (290 points)

It appears that OS X Lion is ignoring ulimit values.  The same program on a Linux 2.6 32bit kernel stops based on the limits as expected


I've set the following via the bash shell.

ulimit -d 25000

ulimit -v 25000

ulimit -a

core file size          (blocks, -c) 0

data seg size           (kbytes, -d) 25000

file size               (blocks, -f) unlimited

max locked memory       (kbytes, -l) unlimited

max memory size         (kbytes, -m) 25000

open files                      (-n) 256

pipe size            (512 bytes, -p) 1

stack size              (kbytes, -s) 8192

cpu time               (seconds, -t) unlimited

max user processes              (-u) 709

virtual memory          (kbytes, -v) 25000


The following program still runs successfully allocating 1M times for 1K each time.  Activity monitor indicates the process has allocated nearly 1 GB.  Why?


#include <stdio.h>

#include <assert.h>



int main (int argc, char * argv[]) {



   static char * p[1000000];

   static int count = 0;



   int i;



   for (i=0; i < 1000000; i++) {



      printf ("%d ", i);

      p[count] = malloc (1024);

      if (p[count] == NULL) break;