473,499 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to increase stack space/heap space

Hi all,
Can I know what is the stack space and heap space allocated by
the compiler.Can i increase it or decrease it.if yes,pleae tell me
theway to do it.Thanks in advance. Cheers, Ajay

May 11 '06 #1
9 7311
Ajay wrote:
Hi all,
Can I know what is the stack space and heap space allocated by
the compiler.Can i increase it or decrease it.if yes,pleae tell me
theway to do it.Thanks in advance. Cheers, Ajay

It's a platform-specific thing, more system related than even compiler
related -- and very much off topic here as it has nothing to do with the
language itself.

HTH,
--ag

--
Artie Gold -- Austin, Texas
http://goldsays.blogspot.com
"You can't KISS* unless you MISS**"
[*-Keep it simple, stupid. **-Make it simple, stupid.]
May 11 '06 #2
"Ajay" <aj***********@gmail.com> wrote.
Hi all,
Can I know what is the stack space and heap space allocated by
the compiler.Can i increase it or decrease it.if yes,pleae tell me
theway to do it.Thanks in advance. Cheers, Ajay

Typically stacks are quite small. On the order of 16K or so.
It may be possible to increase stack size by specifying a compiler option.
However if you need a big stack, probably you have a poor program design.
Big objects are usually varaible in size, and best on the heap.

Usually the compiler will allow all available memory to be allocated on the
heap. In a multi-user system, the maximum allowed is usually set by the
system administrator. In a single user system, usually the only way to
increase ehap size is to buy more meory chips.
--
www.personal.leeds.ac.uk/~bgy1mm

May 11 '06 #3
Malcolm wrote:
"Ajay" <aj***********@gmail.com> wrote.
Hi all,
Can I know what is the stack space and heap space allocated by
the compiler.Can i increase it or decrease it.if yes,pleae tell me
theway to do it.Thanks in advance. Cheers, Ajay

Typically stacks are quite small. On the order of 16K or so.


Sorry, I can't let this go, while off topic, it is also wrong.

There isn't a typical stack size as there isn't a typical environment,
there might not even be a stack. A multi-user system may default to 1
or 2 Mb of stack per thread, while an embedded one may be configured for
a few tens or hundreds of bytes.

The answer is very platform specific, thus off topic here.
It may be possible to increase stack size by specifying a compiler option.
However if you need a big stack, probably you have a poor program design.
Big objects are usually varaible in size, and best on the heap.
Again, wrong. You might have a completely static design.
Usually the compiler will allow all available memory to be allocated on the
heap. In a multi-user system, the maximum allowed is usually set by the
system administrator. In a single user system, usually the only way to
increase ehap size is to buy more meory chips.


This has nothing to do with the compiler, or C.

--
Ian Collins.
May 11 '06 #4
"Ian Collins" <ia******@hotmail.com> wrote in message
news:4c*************@individual.net...
Malcolm wrote:
"Ajay" <aj***********@gmail.com> wrote.
Hi all,
Can I know what is the stack space and heap space allocated by
the compiler.Can i increase it or decrease it.if yes,pleae tell me
theway to do it.Thanks in advance. Cheers, Ajay

Typically stacks are quite small. On the order of 16K or so.


Sorry, I can't let this go, while off topic, it is also wrong.


It's beyond wrong -- there's no guarantee that a "stack" or "heap" even
exists, much less what size it is.
There isn't a typical stack size as there isn't a typical environment,
there might not even be a stack. A multi-user system may default to 1
or 2 Mb of stack per thread, while an embedded one may be configured for
a few tens or hundreds of bytes.

The answer is very platform specific, thus off topic here.


<OT>
Most systems I'm familiar with have the heap grow upward from the "bottom"
of user memory and the stack grow "downward" from the top of user memory.
Either can grow until it meets the other, at which point the program usually
crashes within short order.

The only time you have a fixed stack size is when you create additional
threads; one thread's stack will grow down towards the heap as above, but
other threads' stacks will grow into another stack, which will (eventually)
cause problems even if there's plenty of memory left. This is when compiler
options on stack size become relevant. Of course, C doesn't mention threads
either.
</OT>

--
Stephen Sprunk "Stupid people surround themselves with smart
CCIE #3723 people. Smart people surround themselves with
K5SSS smart people who disagree with them." --Aaron Sorkin
*** Posted via a free Usenet account from http://www.teranews.com ***
May 11 '06 #5
On Thu, 11 May 2006 21:36:12 +0100, "Malcolm"
<re*******@btinternet.com> wrote in comp.lang.c:
"Ajay" <aj***********@gmail.com> wrote.
Hi all,
Can I know what is the stack space and heap space allocated by
the compiler.Can i increase it or decrease it.if yes,pleae tell me
theway to do it.Thanks in advance. Cheers, Ajay

Typically stacks are quite small. On the order of 16K or so.


I'd like to see a 16K stack on an 8051...
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
May 12 '06 #6
Jack Klein wrote:

I'd like to see a 16K stack on an 8051...


I'd like to see a stack on an 8051...
(the setup I used had a 128byte call stack, and no stack variables)

May 12 '06 #7
"Ian Collins" <ia******@hotmail.com> wrote
Typically stacks are quite small. On the order of 16K or so.


Sorry, I can't let this go, while off topic, it is also wrong.

There isn't a typical stack size as there isn't a typical environment,
there might not even be a stack. A multi-user system may default to 1
or 2 Mb of stack per thread, while an embedded one may be configured for
a few tens or hundreds of bytes.

The answer is very platform specific, thus off topic here.

What you have forgotten is that, in C programs, the stack size is
logarithmic.

So if we have a program of 10 functions using 1 Kb of stack space, and a
program with 100 functions uses 2Kb, a program of 1000 functions will take
3Kb, and so forth.

The places this breaks down are some types of recursive algorithms, but not
most of them, since most recursive algorithms also use logarithmic stack
size, and if we allow big items to be placed on the stack. Most C
programmers use the convention that big items are not placed on the stack.
There is a little bit of fuzziness in what is "big".

So the question and answer isn't very platform-specific after all. Stack
usage varies from program to program, of course, but not by as much as the
variation in program size might lead you to believe.
--
Buy my book 12 Common Atheist Arguments (refuted)
$1.25 download or $7.20 paper, available www.lulu.com/bgy1mm

May 13 '06 #8
Malcolm wrote:
"Ian Collins" <ia******@hotmail.com> wrote
Typically stacks are quite small. On the order of 16K or so.
Sorry, I can't let this go, while off topic, it is also wrong.

There isn't a typical stack size as there isn't a typical environment,
there might not even be a stack. A multi-user system may default to 1
or 2 Mb of stack per thread, while an embedded one may be configured for
a few tens or hundreds of bytes.

The answer is very platform specific, thus off topic here.


What you have forgotten is that, in C programs, the stack size is
logarithmic.

Where do you get that from?
So if we have a program of 10 functions using 1 Kb of stack space, and a
program with 100 functions uses 2Kb, a program of 1000 functions will take
3Kb, and so forth.
You could have a program with ten functions where the first calls the
others in turn, or where each calls the next. The stack usage (assuming
for this argument that there is a stack) would be quite different. All
it takes is for one or two functions in the application to use a large
amount of stack space and any speculation is useless.
The places this breaks down are some types of recursive algorithms, but not
most of them, since most recursive algorithms also use logarithmic stack
size, and if we allow big items to be placed on the stack. Most C
programmers use the convention that big items are not placed on the stack.
There is a little bit of fuzziness in what is "big".
Not in a static design they don't.

The field is too broad to draw general conclusions.
So the question and answer isn't very platform-specific after all. Stack
usage varies from program to program, of course, but not by as much as the
variation in program size might lead you to believe.


I didn't mention program size.

--
Ian Collins.
May 13 '06 #9
Ian Collins wrote:

Malcolm wrote:
"Ian Collins" <ia******@hotmail.com> wrote
Typically stacks are quite small. On the order of 16K or so. off topic


That says it all.

--
pete
May 14 '06 #10

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

Similar topics

14
30066
by: Kevin Grigorenko | last post by:
Hello, I couldn't find an obvious answer to this in the FAQ. My basic question, is: Is there any difference in allocating on the heap versus the stack? If heap or stack implementation is not...
2
2464
by: news.tkdsoftware.com | last post by:
Aside from comp.compilers, is there any other forum, newsgroup or medium where I can post questions concerning the development of a byte code compiler & virtual stack machine? --
3
5176
by: gary | last post by:
Hi, 1. About all C/C++ compilers, Does stack increase from high address to low address and heap grow increase from low to high? What on earth decides their increase direction, CPU architecture, OS...
10
8288
by: Shuo Xiang | last post by:
Greetings: I know that variables declared on a stack definitely does not reside in heap space so there is only a very limited amount of stuff that you can store in the stack of a function. But...
1
3754
by: Geiregat Jonas | last post by:
I'm reading Eric Gunnerson's book. He is talking about the heap and stack, he says you have 2types, value wich are in the stack or inline or reference types wich are in the heap. I don't get...
3
1698
by: nahur | last post by:
why do you need a heap and a stack why not all memory called a heap or call it a stack what is the purpose of having a heap and a stack
9
3350
by: shine | last post by:
what is the difference between a heap and a stack?
9
2527
by: coder_lol | last post by:
Thanks everybody for helping me with the Syntax confusion! The implicit conversion stuff really got me :) I have one more question... Array<int32ia; Does the above use the default...
11
2894
by: Nehil | last post by:
I would like to know which is dynamic in nature. if i refer the C memory model (Richard Steven), it is shown that both stack and heap grow towards each other. Now, can one go into other's area and...
0
7007
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
7174
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,...
1
6894
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7388
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...
1
4919
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
4600
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
3099
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1427
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
297
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.