473,511 Members | 14,846 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Heap Size

Hi All,
Could any one tell me, how can I determine/Change size of heap on per-
process basis on Unix based systems.
Thanks.

Regards
Raman Chalotra

Jun 22 '07 #1
7 5603
Raman <ra***********@gmail.comwrites:
Could any one tell me, how can I determine/Change size of heap on per-
process basis on Unix based systems.
Try comp.unix.programmer.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 22 '07 #2
"Keith Thompson" <ks***@mib.orgschrieb im Newsbeitrag
news:ln************@nuthaus.mib.org...
Raman <ra***********@gmail.comwrites:
>Could any one tell me, how can I determine/Change size of heap on per-
process basis on Unix based systems.

Try comp.unix.programmer.
And/or check 'man ulimit'

Bye, Jojo
Jun 22 '07 #3

"Raman" <ra***********@gmail.comha scritto nel messaggio news:11*********************@o11g2000prd.googlegro ups.com...
Hi All,
Could any one tell me, how can I determine/Change size of heap on per-
process basis on Unix based systems.
If by "heap" you mean "memory available for dynamic allocation":

#include <stdio.h>
#include <stdlib.h>
int main(void)
{
size_t size = 1;
unsigned char *p = NULL;
do {
size *= 2;
p = realloc(p, size);
} while (p);
printf("Heap size is less than %lu but more than %lu bytes.\n",
(unsigned long)size, (unsigned long)size / 2);
return 0;
}

But to change it you (if you can) would need system-specific ways.
Try asking a newsgroup about Unix.
Jun 22 '07 #4
"Army1987" <pl********@for.itwrote:
"Raman" <ra***********@gmail.comha scritto nel messaggio
Could any one tell me, how can I determine/Change size of heap on per-
process basis on Unix based systems.
If by "heap" you mean "memory available for dynamic allocation":

#include <stdio.h>
#include <stdlib.h>
int main(void)
{
size_t size = 1;
unsigned char *p = NULL;
do {
size *= 2;
p = realloc(p, size);
} while (p);
printf("Heap size is less than %lu but more than %lu bytes.\n",
(unsigned long)size, (unsigned long)size / 2);
return 0;
}
Do note that the message that is printed may, instead, be "This process
has been terminated by the sysadmin because of runaway memory abuse.",
and the second time you run it it may be "This account has been
temporarily deactivated.NO CARRIER".

IOW, please do not do this on a multi-user system.

Richard
Jun 22 '07 #5

"Richard Bos" <rl*@hoekstra-uitgeverij.nlha scritto nel messaggio news:46***************@news.xs4all.nl...
"Army1987" <pl********@for.itwrote:
>"Raman" <ra***********@gmail.comha scritto nel messaggio
Could any one tell me, how can I determine/Change size of heap on per-
process basis on Unix based systems.
>If by "heap" you mean "memory available for dynamic allocation":

#include <stdio.h>
#include <stdlib.h>
int main(void)
{
size_t size = 1;
unsigned char *p = NULL;
do {
size *= 2;
p = realloc(p, size);
} while (p);
printf("Heap size is less than %lu but more than %lu bytes.\n",
(unsigned long)size, (unsigned long)size / 2);
return 0;
}

Do note that the message that is printed may, instead, be "This process
has been terminated by the sysadmin because of runaway memory abuse.",
and the second time you run it it may be "This account has been
temporarily deactivated.NO CARRIER".

IOW, please do not do this on a multi-user system.
Very fine point. I had temporarily forgotten what happened the last
time I did something like while (1) { p = malloc(200); } on such a
system.
(Also, now I realized what happens if (SIZE_MAX + 1) / 2 bytes of
memory can successfully allocated, and if realloc(p, 0) does not
return a null pointer...)
Jun 22 '07 #6
On Fri, 22 Jun 2007 12:29:22 +0200, "Army1987" <pl********@for.it>
wrote:
>
"Raman" <ra***********@gmail.comha scritto nel messaggio news:11*********************@o11g2000prd.googlegro ups.com...
>Hi All,
Could any one tell me, how can I determine/Change size of heap on per-
process basis on Unix based systems.

If by "heap" you mean "memory available for dynamic allocation":

#include <stdio.h>
#include <stdlib.h>
int main(void)
{
size_t size = 1;
unsigned char *p = NULL;
do {
size *= 2;
p = realloc(p, size);
} while (p);
printf("Heap size is less than %lu but more than %lu bytes.\n",
(unsigned long)size, (unsigned long)size / 2);
return 0;
}

This does not relate to the total amount available but to the largest
contiguous block available and even then it could report a number much
too low.
Remove del for email
Jun 22 '07 #7
>>>>"Army" == Army1987 <pl********@for.itwrites:

Army"Raman" <ra***********@gmail.comha scritto nel messaggio
Armynews:11*********************@o11g2000prd.googl egroups.com...
>Hi All,
Could any one tell me, how can I determine/Change size of heap
on per- process basis on Unix based systems.
ArmyIf by "heap" you mean "memory available for dynamic
Armyallocation":

Army#include <stdio.h>
Army#include <stdlib.h>
Armyint main(void)
Army{
Army size_t size = 1;
Army unsigned char *p = NULL;
Army do {
Army size *= 2;
Army p = realloc(p, size);
Army } while (p);
Army printf("Heap size is less than %lu but more than %lu
Army bytes.\n",
Army (unsigned long)size, (unsigned long)size / 2);
Army return 0;
Army}

ArmyBut to change it you (if you can) would need system-specific
Armyways. Try asking a newsgroup about Unix.
I don't think this does what the OP wants since realloc can (and on my
system does) change the size of the heap when it needs to.

<OT>
The heap size can be changed on Unix systems, man sbrk.
</OT>
Jun 25 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
7950
by: Mark | last post by:
I am using JVM version 1.4.1 (java.vm.version=1.4.1-1) to run my program on UNIX. I use java command line option "java" to invoke my program. How will I know what the default heap size settings...
1
40529
by: Oleg Konovalov | last post by:
Hi, I am running applets in Java Plug-in 1.4.2 under IE6 and often receive OutOfMemory exceptions (dealing with large file - video clips, etc.) although according to option M, almost 50% (out...
3
495
by: nvjoglekar | last post by:
Hi All My program needs a lot of memory and after allocating some using NEW statement, it returns NULL for any new object created. I guess that is becuase of the heap size limitation of the...
1
8206
by: nrhayyal | last post by:
hi all, i am working on C++ on AIX machine. i am running one of my module which is built using 10+ user built libraries. i am getting St9bad_alloc exception. i came to know that this exception...
4
16610
by: ivan | last post by:
Hi, How can we calculate the stack and heap size requried by a C program. Is there any specific formula used? Please suggest. regards, Ivan
1
2571
by: Exal | last post by:
Hi, could anyone help me or point me to a site where to find information about how to track the heap size and garbage collections during the execution of an application? Thanx
11
17623
by: ganesh.kundapur | last post by:
Hi, Is there any way to get the total heap size allocated to a process in c on linux platform. Regards, Ganesh
5
37090
by: sunny | last post by:
Hi All Is there any way to determine stack and heap size, during runtime. i.e can we predict stack overflow. etc
2
1191
by: Paul | last post by:
Dear all, I am writing an application which constructing a fairly big tree for some financial pricing application. How can I increase the heap size of the .NET runtime environment? I have...
0
7252
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7371
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7517
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5676
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5077
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1583
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.