size of stack and heap for main programs

size of stack and heap for main programs

Post by William Paul Berris » Thu, 17 Apr 1997 04:00:00



Hi

I use a Sun SPARC 5 running Solaris 2.5, and I have 32MB
of RAM on one machine.  (Another server has 2 gigabytes of RAM).

I have an Ada program which tries to create a 3D array of
size 128 X 128 X 128 bins of Integers (4 byte types),
i.e. asks for 8 Megabytes of RAM.
I have written it two ways, one as normal (asking for
stack space) and one using pointers and new (asking for
heap) space.

   Both programs crash giving  Segmentation Fault!

(It says Storage_Error on a friend's old Ada compiler
as it should do (this means stack overflow), but nevermind.)

However, if I ask for a smaller array of size 85X85X85 bins say,
then all works fine!

I am told that the size of the stack allowed for the main program
can grow as big as it wants to be, limited only by the
hardware and operating system.  Since I have access to a machine
with a big RAM (32 MB or more) and I am only asking for
8 Megs, I wish to know why I get this Segmentation Fault.

**The QUESTION

    Can you tell me what the max size of the stack is
    for a single executable program (or how I can find
    it out for my machine + OS)?
    AND
    how I can ask for a bigger stack / make the stack bigger.

(I am assured that the compiler does not limit the max size of the
stack for the main program.)

Thanks in advance.

Will Berriss
--------------

--


Department of Engineering
The University of Reading
Whiteknights
Reading                     Tel:  0118 987 5123
Berkshire                     (+44 118 987 5123 outside UK)
RG6 6AY    
England                     Fax:  0118 931 3327    

World Wide Web Home Page:

http://www.elec.rdg.ac.uk/people/postgrads/will.html

 
 
 

size of stack and heap for main programs

Post by mik.. » Sun, 20 Apr 1997 04:00:00


On Wed, 16 Apr 1997 14:45:52 +0100, William Paul Berriss


>Hi

>I use a Sun SPARC 5 running Solaris 2.5, and I have 32MB
>of RAM on one machine.  (Another server has 2 gigabytes of RAM).

>I have an Ada program which tries to create a 3D array of
>size 128 X 128 X 128 bins of Integers (4 byte types),
>i.e. asks for 8 Megabytes of RAM.
>I have written it two ways, one as normal (asking for
>stack space) and one using pointers and new (asking for
>heap) space.

>   Both programs crash giving  Segmentation Fault!

>(It says Storage_Error on a friend's old Ada compiler
>as it should do (this means stack overflow), but nevermind.)

>However, if I ask for a smaller array of size 85X85X85 bins say,
>then all works fine!

>I am told that the size of the stack allowed for the main program
>can grow as big as it wants to be, limited only by the
>hardware and operating system.  Since I have access to a machine
>with a big RAM (32 MB or more) and I am only asking for
>8 Megs, I wish to know why I get this Segmentation Fault.

>**The QUESTION

>    Can you tell me what the max size of the stack is
>    for a single executable program (or how I can find
>    it out for my machine + OS)?
>    AND
>    how I can ask for a bigger stack / make the stack bigger.

>(I am assured that the compiler does not limit the max size of the
>stack for the main program.)

>Thanks in advance.

>Will Berriss
>--------------

>--


>Department of Engineering
>The University of Reading
>Whiteknights
>Reading                     Tel:  0118 987 5123
>Berkshire                     (+44 118 987 5123 outside UK)
>RG6 6AY    
>England                     Fax:  0118 931 3327    

>World Wide Web Home Page:

>http://www.elec.rdg.ac.uk/people/postgrads/will.html

I would try sysdef -i to see your stack size.
Maybe read the man page on ulimit too.

 
 
 

1. Measuring the size of stack and heap

Dear Netters:

I am making major changes to an existing program and would
like to know how these changes would affect the heap and
stack sizes of the program. Sometime ago, someone suggestted
that I use svmon to do it.

The following is the output of svmon on the program:


Pid                         Command        Inuse        Pin      Pgspace
17309                             PROG         2099          2         2872

Pid:  1730PROG
Command:  gws

Segid  Type  Description         Inuse   Pin  Pgspace   Address Range
 374d  pers  /dev/hd2:53411          0     0       0    0..-1
 6338  pers  /dev/hd2:53388          0     0       0    0..-1
 785e  pers  /dev/hd2:53386          1     0       0    0..0
 2409  work  shared library        700     0    1741    0..2022 : 60123..65535
 1485  work  sreg[4]                11     0      11    0..10 : 65536..65535
 747c  work  sreg[3]                 1     0       1    0..0 : 65536..65535
 10c5  work  private              1148     2    1119    0..1247 : 65402..65535
 7a5e  pers  code,/dev/hd2:46410   238     0       0    0..1165

So from this output, how can I find out the size of heap or stack?

Thanks.

2. Cox@home - no servers - sometimes

3. tool? code, data, stack, heap, shm sizes

4. IP Masqerading and JDK on a 386?

5. Deleting shared-library allocated heap objects in main-program

6. Memory Error on a E420R?

7. How can I know my heap and stack size in running time?

8. Terminal Services on Linux?

9. getprocs does not return stack and heap size separately?

10. shmat() and max stack/heap size

11. "increased VM size+Main-memory" better than "Main-memory+Hard-disk" ??

12. stack - max stack size (KB)

13. Program Stack Size