Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


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

Rep: Reputation: 15
Modifying the heap available to a process


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:

#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;

int main( )
new int[10000];

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!



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 12:28 AM
Find out heap size for a PID luexiong Linux - General 1 03-29-2005 09:40 AM
increasing heap size podollb Linux - Software 3 03-06-2005 11:42 PM
dumping and browsing heap with gdb Hano Programming 0 07-15-2004 10:55 PM
"wine: failed to create the process heap", in Fedora Core 2 crimsonmoon Linux - Software 3 06-16-2004 04:59 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:20 PM.

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