Ultimate Amiga

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Out of stack space error  (Read 3778 times)

0 Members and 1 Guest are viewing this topic.

robertframpton

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 8
Out of stack space error
« 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?
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Out of stack space error
« Reply #1 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.
Logged

robertframpton

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 8
Re: Out of stack space error
« Reply #2 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.
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Out of stack space error
« Reply #3 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?
Logged
Pages: [1]   Go Up
 

TinyPortal 2.2.2 © 2005-2022