modifying heap available to a process
Hello,
I'm pretty new to Linux and I'm trying to figure out
how to modify the amount of heap available to a
process. I have the following simple C++ program:
//START CODE
#include <iostream>
#include <cstdlib>
#include <new>
using namespace std;
int count = 0;
void out_of_memory( )
{
cerr << "memory exhausted after " << count << "
allocations!" << endl;
cerr << "or " << count * 10000 * sizeof(int) << "
bytes" << endl;
exit(1);
}
int main( )
{
set_new_handler(out_of_memory);
while(1)
{
count++;
new int[10000];
}
}
//END CODE
When I run this program the output is:
memory exhausted after 76677 allocations!
or 3067080000 bytes
I would like to limit the heap available to the
process. I think ulimit should be able to do what I
want but I've not had any luck yet. (As an aside is
their any documentation available for the bash
builtins anywhere?) If I issue 'ulimit -m 2' and then
'ulimit -a' it seems to indicate that max memory has
been set to 2k but when I run the program again I get
the same output. So, can anyone tell me how to limit
the heap available to a process? Thanks in advance
for any replies!
-exits
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
_______________________________________________
Redhat-devel-list mailing list
Redhat-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/redhat-devel-list
[Kernel Newbies]
[Red Hat General]
[Fedora]
[Red Hat Install]
[Linux Kernel Development]
[Yosemite News]