I've wrote sample program in C++:
#include<cstdio>
#include<cstdlib>
long long T[5000000];
int main(){
for(int i=0;i<5000000;i++) T=rand()%5000000;
for(int i=0;i<5000000;i++) T=T[rand()%5000000];
printf("%lld\n",T[rand()%5000000]);
return 0;
}
It uses memory: ~40MB
But when I check it in terminal:
dzwiedziu:~/test_ulimit # ulimit -v 1000
dzwiedziu:~/test_ulimit # ./test
1480040
dzwiedziu:~/test_ulimit # ulimit -H -a
core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) 1000
open files (-n) unlimited
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 65532
cpu time (seconds, -t) unlimited
max user processes (-u) 532
virtual memory (kbytes, -v) 1000
This program should be killed. I've worked on linux for 4 years. What's wrong?
#include<cstdio>
#include<cstdlib>
long long T[5000000];
int main(){
for(int i=0;i<5000000;i++) T=rand()%5000000;
for(int i=0;i<5000000;i++) T=T[rand()%5000000];
printf("%lld\n",T[rand()%5000000]);
return 0;
}
It uses memory: ~40MB
But when I check it in terminal:
dzwiedziu:~/test_ulimit # ulimit -v 1000
dzwiedziu:~/test_ulimit # ./test
1480040
dzwiedziu:~/test_ulimit # ulimit -H -a
core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) 1000
open files (-n) unlimited
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 65532
cpu time (seconds, -t) unlimited
max user processes (-u) 532
virtual memory (kbytes, -v) 1000
This program should be killed. I've worked on linux for 4 years. What's wrong?