02 August 2014, 18:15 | #1 |
Registered User
Join Date: Sep 2013
Location: Bettendorf, IA, USA
Age: 52
Posts: 204
|
Stack available
My program uses a lot of small images and requires a larger stack size. I know how to check the total stack size
Code:
StackSize=(LONG)SysBase->ThisTask->tc_SPUpper-(LONG)SysBase->ThisTask->tc_SPLower; I open my program, load the images, do whatever, check how much stack is used/available to determine if I need to set a larger stack in case down the road I load more images, variables, etc. I don't want to just set a random high stack size if I don't really need to. But also don't want it too low. |
02 August 2014, 21:12 | #2 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,985
|
Code:
UBYTE *get_current_stack_pointer (void) { UBYTE dummy; return (&dummy); } struct Task *mytask = FindTask(NULL); used_stack = (UBYTE *)mytask->tc_SPUpper - get_current_stack_pointer(); However, I strongly doubt that you really have a dynamic change of stack size requirements. Required stack mostly depends on the number of nested subroutine calls and the number of arguments and local variables of these subroutines. The maximum number of nesting subroutines usually only depends on the design of your program and not on the incoming data. Only if your subroutines call themselves recursively, then the nesting depth is dependent on the data. There are stack snoop programs on Aminet. They run your program and when it ends they tell you how much stack it used at most. Depending on this value you can set a static size for the stack at the beginning of your program. Note that you cannot change the stack size while you already use the stack. The StackSwap routine gives you a completely new (empty) stack. You cannot even exit the routine which called StackSwap without swapping it back to the old stack. |
03 August 2014, 04:53 | #3 |
Coder/webmaster/gamer
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,630
|
I use StackAttack to see how much stack is being used...
|
03 August 2014, 10:36 | #4 |
Ruler of the Universe
Join Date: Mar 2010
Location: Lanzarote/Spain
Posts: 6,185
|
|
03 August 2014, 18:31 | #5 |
Registered User
Join Date: Sep 2013
Location: Bettendorf, IA, USA
Age: 52
Posts: 204
|
I like StackSnoop. Does what I was looking for in a nice visual manner. I am using less stack than what I thought.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Apollo stack? | JuvUK | support.Apps | 21 | 22 December 2008 14:59 |
TCP/IP stack | Doc Mindie | request.Apps | 14 | 20 September 2007 15:58 |
TCP/IP stack help please! | Chris1965 | support.Apps | 9 | 24 March 2007 12:00 |
Stack Up | Galaxy | request.Old Rare Games | 5 | 08 September 2004 03:06 |
Who wants a stack of originals? | FromWithin | Games images which need to be WHDified | 41 | 31 July 2003 09:31 |
|
|