Re: How to calculate the stack and heap size
- From: Flash Gordon <spam@xxxxxxxxxxxxxxxxxx>
- Date: Thu, 20 Oct 2005 12:25:12 +0100
ivan wrote:
Hi,
How can we calculate the stack and heap size requried by a C program. Is there any specific formula used?
There is no standard way to calculate the stack size required, since 1) The C standard does not require a stack 2) You can't tell whether local variables will have memory associated at all, they might just be kept in registers or the compiler may find a way to eliminate some all together 3) There could be any or no padding between parameters
You can estimate it if you know how your implementation does things, although if you use recursion this can be very difficult.
There is no standard way to determine how much heap us used because 1) The C standard does not require a heap 2) Different heap management schemes have different overheads 3) It depends on how good your implementation is at reusing freed memory
Again, if you know your implementation well enough it may be possible to estimate this.
Please suggest.
I suggest that you ask somewhere dedicated to your system since it is highly system specific. This suggestion is for your benefit as much as ours.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
.
- References:
- How to calculate the stack and heap size
- From: ivan
- How to calculate the stack and heap size
- Prev by Date: Re: Looking for a C program to parse CSV
- Next by Date: Re: Looking for a C program to parse CSV
- Previous by thread: How to calculate the stack and heap size
- Next by thread: Re: How to calculate the stack and heap size
- Index(es):
Relevant Pages
|