Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do COMMON SHARED variables take up stack space?

Status
Not open for further replies.

sandmann999

Programmer
Apr 28, 2001
52
US
Hey everyone, I'm running into the OUT OF STACK SPACE error. I know what the error means and what the stack is, but I'm curious what I can do to clean up some space without using CLEAR (which is not an option by any means). I have a LOT of COMMON SHARED variables that pass between several modules in my game, such as MAIN.BAS, STATUS.BAS, FIGHT.BAS, etc... Do these COMMON SHARED variables take up stack space for every sub I go into?
 
The memory diagrams show COMMON existing in DGROUP, outside of the stack:
And the statement "To work around this problem, dimension the TYPEd array with DIM SHARED or put it in a COMMON SHARED statement" from the following KB implies that COMMON SHARED does not use the stack:
 
I see you have not responded yet. Maybe you want a simpler answer.

COMMON SHARED variables take up space before every other SUB or FUNCTION.

If you do
COMMON SHARED x(1000) as string
or just
DIM SHARED x(1000) as string
then the amount of storage needed to support that array will be unavailable to all SUB's and FUNCTION's or even MAIN even if the array is never used.

Does that answer your question?

Mac

 
Thanks for the responses. Both explained a lot as to how stack space works. It turns out that my error was caused by small bug that I fixed that caused a recursion, but now I have a temporary code that pops up how much memory I have left (numeric, string, and stack) as the program's running and that helps a lot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top