English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 02 August 2014, 18:15   #1
mritter0
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;
Is there a way to check how much is available/used?

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.
mritter0 is offline  
Old 02 August 2014, 21:12   #2
thomas
Registered User
 
thomas's Avatar
 
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.
thomas is offline  
Old 03 August 2014, 04:53   #3
Minuous
Coder/webmaster/gamer
 
Minuous's Avatar
 
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,630
I use StackAttack to see how much stack is being used...
Minuous is offline  
Old 03 August 2014, 10:36   #4
Retrofan
Ruler of the Universe
 
Retrofan's Avatar
 
Join Date: Mar 2010
Location: Lanzarote/Spain
Posts: 6,185
Quote:
Originally Posted by Minuous View Post
I use StackAttack to see how much stack is being used...
So if I use StackAttack from the s-s I don't need to use an Stack command with a size to run any program?
Retrofan is offline  
Old 03 August 2014, 18:31   #5
mritter0
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.
mritter0 is offline  
 


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 13:05.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.13515 seconds with 13 queries