LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-10-2003, 10:20 PM   #1
exitsfunnel
Member
 
Registered: May 2003
Distribution: RedHat
Posts: 60

Rep: Reputation: 15
Modifying the 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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Modifying process descriptor in device driver drminix Linux - Software 1 06-12-2005 01:28 AM
Find out heap size for a PID luexiong Linux - General 1 03-29-2005 10:40 AM
increasing heap size podollb Linux - Software 3 03-07-2005 12:42 AM
dumping and browsing heap with gdb Hano Programming 0 07-15-2004 11:55 PM
"wine: failed to create the process heap", in Fedora Core 2 crimsonmoon Linux - Software 3 06-16-2004 05:59 AM


All times are GMT -5. The time now is 03:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration