I'm not sure if you still need an answer to this question, but here is the answer to the case if someone else has the same question.
ulimit -m severely limits resident memory, not the amount of memory that a process may request from the operating system.
ulimit -v limit the amount of virtual memory that a process can request from the operating system.
eg...
#include <stdio.h> #include <stdlib.h> int main(int argc, char* argv[]) { int size = 1 << 20; void* memory = NULL; memory = malloc(size); printf("allocated %i bytes...\n", size); return 0; }
ulimit -m 512 ./memory allocated 1048576 bytes...
ulimit -v 512 ./memory Segmentation fault
If you run ulimit -a , it should provide a summary of all current restrictions for child processes.
As mentioned in the comments below @ bikram990, the java process may not abide by soft restrictions. To force the use of Java memory limits, you can pass arguments to the process (-Xmx, -Xss, etc.).
Attention!
You can also set hard limits with the ulimit -H command which cannot be changed by subprocesses. However, these restrictions also cannot be raised again after reduction, without increased permissions (root).
Jason
source share