Hi John,

I will answer your questions as best I can but I think you have some
confusion over what the call stack is, how it works, and therefore may
be worrying about nothing.

First, as to your question there is no way to kill the stack with out
killing the entire program. If your function that clears the stack
returns there would essentially be nothing left in memory to return to
resulting in a crash. Quite frankly put since the stack holds the
memory address of every function and variable in your program if you
kill the stack you might as well kill the entire program since there
are essentially no functions and variables in memory to access.

Second, as for creating the size of the call stack don't worry about
it too much. If you are paranoid about this all you have to do is some
very memory efficient coding such as instead of using a lot of global
variables pass information by reference to functions and use local
variables as often as possible. Every time a function returns the
function itself is released from the stack, and any variables etc
contained there in are also removed freeing up more memory on the
stack for more functions and variables.

I don't honestly see you having a serious stack overflow here, because
BGT seems to have a reasonably large enough call stack for any game
you can conceive of. Its not about how many functions you have in the
program or how many times you call them. As I said every time a
function returns the function is removed from the stack along with any
pointers, objects, and variables it may contain in the local scope so
its not like that stuff remains in memory forever. Sooner or later it
will get removed from the stack making room for something else.

That said, using loops like a while loop is more memory efficient than
using recursion. In other words if you need to perform the same action
multiple times instead of simply calling the same function over and
over again, (recursion,) put it in a loop so that the function only
gets called when a certain state is true, and if not the loop exits
and the function can be removed from the stack.

Cheers!



On 8/29/14, john <jpcarnemo...@gmail.com> wrote:
> HI all,
>       As the subject suggests, I'm wondering if its possible to clear (or
> increase the size of) the call stack in bgt (or any programming language,
> for that matter). I'm having difficulty from keeping my projects from
> continually increasing the size
> of the stack, and while this would be just fine for a small program, I'm
> pretty sure my major project is going to go over 10000 eventually, possibly
> regardless of how perfectly the player performs. If there's no way to do
> this, are there any tips I
> can get as to how to make a program continue running without increasing the
> call stack, as I'm going to have to be constantly switching between
> functions, that need to be able to call each other a theoretically infinite
> number of times.
>
> ---
> Gamers mailing list __ Gamers@audyssey.org
> If you want to leave the list, send E-mail to
> gamers-unsubscr...@audyssey.org.
> You can make changes or update your subscription via the web, at
> http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
> All messages are archived and can be searched and read at
> http://www.mail-archive.com/gamers@audyssey.org.
> If you have any questions or concerns regarding the management of the list,
> please send E-mail to gamers-ow...@audyssey.org.
>

---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gamers@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.

Reply via email to