Board index » delphi » Problem with heap overflow errors

Problem with heap overflow errors

Yet another problem for my game, now after the program has run several
times, it crashes due to a heap overflow error, i have the program in a loop
which executes several procedures several times. does anyone know how to
assign more memory or even better clear the memory of procedures passed?

Thanks for any help you guys can give!
Xenolith.

 

Re:Problem with heap overflow errors


In article <ktUe5.2015$gg.5...@news1.rivrw1.nsw.optushome.com.au>,

Quote
Xenolith <wildf...@fsf.com.au> wrote:
>Yet another problem for my game, now after the program has run several
>times, it crashes due to a heap overflow error, i have the program in a loop
>which executes several procedures several times. does anyone know how to
>assign more memory or even better clear the memory of procedures passed?

So you want just to take pain killers for a broken arm?

How about fixing the memory leak from your code? It is your code, so
fix it. We cannot read your mind and see where the problem is.

You might try monitoring memavail to see where the leak is-.

Osmo

Re:Problem with heap overflow errors


Quote
>Xenolith <wildf...@fsf.com.au> wrote:
>>Yet another problem for my game, now after the program has run several
>>times, it crashes due to a heap overflow error, i have the program in a loop
>>which executes several procedures several times. does anyone know how to
>>assign more memory or even better clear the memory of procedures passed?

>So you want just to take pain killers for a broken arm?

>How about fixing the memory leak from your code? It is your code, so
>fix it. We cannot read your mind and see where the problem is.

>You might try monitoring memavail to see where the leak is-.

If it is 32-bit clean code, compile it with FPC (with -gl and -Sh as
parameters)
It will print a lot of heap debugging info (sometimes even the filename and
line the bad allocation was done).

Re:Problem with heap overflow errors


Quote
"Xenolith" <wildf...@fsf.com.au> wrote:
>Yet another problem for my game, now after the program has run several
>times, it crashes due to a heap overflow error, i have the program in a loop
>which executes several procedures several times. does anyone know how to
>assign more memory or even better clear the memory of procedures passed?

You may need to Dispose or FreeMem.  Make sure you're not
redeclaring dynamic inside the loop w/o freeing it.

Jud McCranie

Re:Problem with heap overflow errors


Quote
>Yet another problem for my game, now after the program has run several
>times, it crashes due to a heap overflow error, i have the program in a
loop
>which executes several procedures several times. does anyone know how to
>assign more memory or even better clear the memory of procedures passed?

If the amount of data can be foreseen right from the beginning of your game,
you could also try to extract all commands refering to memory (de)allocation
from the main part of your game. So you could create two procedures called
like "AllocMemory" and "FreeMemory" containing _all_ those "getmem" and
"dispose" statements. By this means you might be able to verify that memory
is only assigned _once_ to a single pointer, and it can make your source
code more transparent.. maybe ;-) At least, it helped me once when I had
quite a similar problem within a game, where a sinus/cosinus-table was
allocated each time you re-started it.. it's not the heap nor the compiler-
it's normally your confusion ;-)).

Have a try - maybe it helps

Other Threads