[AWS] Problem with stack limits
David Marceau
davidmarceau@sympatico.ca
Wed, 03 Mar 2004 15:23:55 -0500
OPTION #1
----------
Taken from:
http://www.rtems.com/rtems/maillistArchives/rtems-users/2001/june/msg00155.html
I think I saw you mention something like this:
-- 2MB bytes allocated to instances of A_Task_Type
task type A_Task_Type;
for A_Task_Type'STORAGE_SIZE use 2_097_152;
A_Task : A_Task_Type;
-- 4MB bytes allocated to instances of B_Task_Type
task type B_Task_Type;
for B_Task_Type'STORAGE_SIZE use 4_194_304;
B_Task : B_Task_Type;
OPTION #2
---------
>--stack=0x10000
>4MB
>2MB
I recommend you use explicitly give a commit option also.
It seems you are just using the implicit default commit option by default(for
example 0x1000 which is 4K).
As it stands, explicitly you specified only the reserve option to 0x10000(hex) =
65536 (decimal) Kbytes.
Try explicitly stating both 1)reserve, 2)commit.
Humor me:
--stack=0x1000,0x1000
--stack=0x10000,0x10000
--stack=0x200000,0x200000
--stack=0x200000,0x200000
--stack=0x400000,0x400000
Taken from:
http://www.cygwin.com/ml/cygwin/1997-08/msg00088.html
gnatlink hello -Xlinker --stack=[reserve],[commit]
The reserve argument sets the amount of memory the system should reserve in the
address space for the thread's stack.
The commit argument specifies the amount of reserved address space that should
initially be committed to the stack.
gnatlink hello -Wl,--stack=[reserve]
Note it seems with with -Wl option it is not possible to set the stack commit
size because the coma is a separator for this option.
OPTION #3
--------
You mentioned before:
>ulimit -s unlimited
What have you got for this?
ulimit -a
core file size (blocks) 1000000
data seg size (kbytes) unlimited
file size (blocks) unlimited
max locked memory (kbytes) unlimited
max memory size (kbytes) unlimited
open files 1024
pipe size (512 bytes) 8
stack size (kbytes) 8192
cpu time (seconds) unlimited
max user processes 4096
virtual memory (kbytes) unlimited
Taken from:
http://www.cs.nyu.edu/exact/core/download/core_v1.5/core_v1.5/doc/stackOverflow.txt
Linux:
======
> ulimit -a # shows the current stack size
> ulimit -s 32768 # sets the stack size to 32M bytes
If you can set it per process using an api call do this instead. I don't think
it's a good idea to set the stack size to 32M for every process running on your
machine. Only the necessary processes in question. Something like pthread
setstacksize().
Windows (during compilation):
=============================
1. Select "Project->Setting".
2. Select "Link" page.
3. Select "Category" to "Output".
4. Type your preferred stack size in "Reserve:" field under "Stack
allocations". eg, 32768 in decimal or 0x20000 in hexadecimal.
Windows (to modify the executable file):
=======================================
There are two programs included in Microsoft Visual Studio, "dumpbin.exe"
and "editbin.exe". Run "dumpbin /headers executable_file", and you can see
the "size of stack reserve" information in "optional header values". Run
"editbin /STACK:size" to change the default stack size.
OPTION ???
-----------
Any others ?:)
I can think of a drastic one by increasing a contant for STACK in libc and
recompiling it :)