Ultimate Amiga

Network Boards => AMOS Language Discussion => AMOS Factory => AMOS Forum => Topic started by: robertframpton on August 07, 2006, 07:34:58 AM

Title: Out of stack space error
Post by: robertframpton on August 07, 2006, 07:34:58 AM
Does anyone know how I can avoid getting out of stack space errors (whilst within AMOS, or software failure once the program is compiled)?

  I have re-designed my program so that none of my procedures are recursive and do not call themselves.

  I know you can use the command set stack followed by the maximum number of recursive procedure calls, but surely I will still eventualy run out of stack space however big I make the number?

  I have tried making the set stack number very large, but this tends to crash the computer.

  Are there ways to solve this problem without using set stack?
Title: Re: Out of stack space error
Post by: SamuraiCrow on August 07, 2006, 06:00:12 PM
It sounds like you're doing the right kind of experimentation to get it working.  One thing to consider with Amos is that it allocates its own stack and detatches itself from the calling task.  It's possible that the calling task's stack may be what is causing your program to fail rather than the stack that Amos allocates.

Just as a point of reference are you running your program on a 1 meg system? Are you running on a system with all CHIP RAM?  It is possible that there is graphics in one of your banks that there isn't enough memory left to allocate the stack.  I don't think this is the case but you might want to try it anyway.

Post back here to let us know how it turns out.

-edit-  I just thought of one more possibilty:  If you are allocating an array in a loop and not deallocating it anywhere could cause you to run out of memory as well.  This is the most common "memory leak" in C and may also manifest itself in other languages.
Title: Re: Out of stack space error
Post by: robertframpton on August 11, 2006, 10:56:46 AM
With reference to your third tip.

  I do not know how and cannot find any mention of how to dealocate an array in the Amos Pro manual.

  As far as my arrays go there sizes are set at the begining of the program outside of all my procedures, followed by the dimensioning of the arrays, followed by defining the variables and sizes used in the arrays as global variables.

  After this I start to call my procedures during which data is read into my arrays. Could this be were I am going wrong?

  I am running my program on an A1200 with 2 Meg chip ram and no fast ram.
Title: Re: Out of stack space error
Post by: SamuraiCrow on August 11, 2006, 05:23:27 PM
Sorry, I must have been thinking of Microsoft QBasic which had a command called REDIM that would allow changing of the size of an allocated array and another command that would deallocate the array.

It sounds like you have your arrays defined correctly.  The only thing I can think of that would overflow the stack is if you have too many local variables for the amount of stack space that you're allocating.  It shouldn't matter much for non-recursive programs though and you said you were allocating more stack and it still crashed.

Maybe it's a bug in Amos itself.  What version are you compiling under?