You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

limit values ignored

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;

count++;



}

}

Posted on Aug 28, 2011 9:17 AM

Reply
2 replies

Aug 31, 2011 9:28 PM in response to etresoft

That document sounds like rationale written by someone who forgot to do the job. Limits can provide a degree of sand-boxing. I agree that a well-behaved program should not need such protections, but some programs are written with ill intent and other are written without the full degree of process and protections that are possible to ensure good behavior. Oh, well, so be it. Thank you, for the answer.

limit values ignored

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.