Fedora Linux Support Community & Resources Center
  #1  
Old 1st August 2007, 05:23 AM
rajat123 Offline
Registered User
 
Join Date: Jan 2007
Posts: 24
How to increase Heap Size?

Hi Folks!

I'm facing lot of segmentation faults in my code. I tried using some memory debugger like valgrind but all in vain as they make my application a lot slower and due to which my application does not work at all. And so I'm not able to debug my code.

I'm thinking of increasing the Heap Size of system which is a Fedora Core 6, kernel 2.6.18

1. Please suggest if this is a wise idea to increase the heap when there is problem debugging the code?

2. Also, suggest how can I increase the Heap Size of my machine?

3. Is there any harm to system with increase in the heap size?

Thanks and Regards,
Rajat
Reply With Quote
  #2  
Old 1st August 2007, 05:57 AM
lazlow Offline
Registered User
 
Join Date: Aug 2005
Posts: 3,172
I am not sure but I think you may want to increase the stack size. I THINK that the heap is limited by the program and not by the kernel(except when you run out of address space). You might want to look at:

http://www.thescripts.com/forum/post237960-7.html
Reply With Quote
  #3  
Old 1st August 2007, 11:38 AM
nhydra Offline
Registered User
 
Join Date: Aug 2006
Age: 30
Posts: 61
You definitely have a problem with the stack variables. Look around and remove any dangerous local variables. it is impossible to get segfault because of stack size in appropriate working program.
do you use some recursion or iteration algorithms? probably this is your problem.
look about this example.

int a (int c){
char asd[256];
for (;
a(12);
}

this will make segfault because of stack overflow. so, do not do this in your code.

Last edited by nhydra; 1st August 2007 at 11:54 AM.
Reply With Quote
  #4  
Old 1st August 2007, 11:47 AM
Reisswolf's Avatar
Reisswolf Offline
Registered User
 
Join Date: May 2006
Posts: 333
I don't see how increasing the size of the heap will necessarily eliminate the segmentation faults.

Try using breakpoints in gdb to see where you are getting the errors. In all likelihood the problem lies in your code, not in the size of the heap.

Roughly speaking, the only way you could end up with segmentation faults in a perfectly coded programme is if some external programme modified (or eliminated) some variable stored in the heap. But Linux would not, or at least should not, allow that, since the kernel runs in the protected mode (which means that the memory area of one programme is protected from the other programmes).

Are you using shared memory in your programme? (Basically, are you using the shmget() function, and its friends, in C?) If so, then check your programme for race conditions to make sure that data integrity is maintained.

Honestly, I don't think the size of the heap is at fault here.
__________________
Registered user # 441814
Reply With Quote
Reply

Tags
heap, increase, size

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
LVM increase size question DubJohn Installation and Live Media 1 2nd July 2009 04:08 PM
Increase RFS size kirubakonig Hardware & Laptops 1 23rd February 2009 06:28 AM
how to increase the swap size karthik2fun Using Fedora 7 25th July 2008 03:12 PM
Increase size of /dev/hda1 lothario Using Fedora 3 25th May 2005 02:15 PM


Current GMT-time: 06:01 (Monday, 20-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat