Stack Overflow problem

Hi programmer.....

I have just started making my first game (or trying to)

in TP 7.0, but when i compile the program and run it it tells me that a stack overflow error has occured...

The source code is only about 50 lines, but i use a unit which is about 500 lines. The procedures i am using have to get about 5-6 parametres....Is that to much or what????

What do i have to do to solve this.....

Oh, i have tried with the $M directive but it doesn't seem to work....



  • 3 main possibilities:

    1. the unit is doing something wrong (or just requires a whole lotta mem)

    2. you are trying to getmem a LOT of space in those 50 lines

    3. you are writing at some illegal memory positions causing the crash.

    You could ofcourse mail me your source+unit and I could figure it out for you.


    The Watcher^TUHB


  • I see the problem in the procedures with 5-6 parameters.

    All parameters passed by value (i.e. without "var" prefix)

    are copied onto the stack. If you pass some array to function,

    you should pass it as "var" parameter, or you are going to

    get Stack Overflow.

    The very same thing is valid about bigger records.

    So check your program for those big parameters passed by value

    and convert them to passed by reference.

    (The best place to start is the procedure, where the runtime

    error occurs!)


    Peter "Dragon" Kadlec

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!