On Mon, 8 Dec 2003 19:34:02 -0800 (PST), exits funnel wrote: > 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?) man ulimit man bash > 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! Limit the virtual memory, option -v. _______________________________________________ Redhat-devel-list mailing list Redhat-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/redhat-devel-list