×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Do COMMON SHARED variables take up stack space?

Do COMMON SHARED variables take up stack space?

Do COMMON SHARED variables take up stack space?

(OP)
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?

RE: Do COMMON SHARED variables take up stack space?

The memory diagrams show COMMON existing in DGROUP, outside of the stack: http://support.microsoft.com/kb/45850

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: http://support.microsoft.com/kb/57711

RE: Do COMMON SHARED variables take up stack space?

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

RE: Do COMMON SHARED variables take up stack space?

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close