Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Heap help
Hi boriel,

I wondered if you could help me understand the heap a little better? Reading the forum I've determined that the heap is mainly used for string handling and by default is just over 4k in length (but may take up the rest of memory - is that right?)

My program is fairly large (just over 30K when compiled with -O2, I am compiling from address 24576 to give me extra space). When running it does quite a lot of string manipulation and I've noticed that it becomes steadily more unstable over time until it finally crashes, either with an 'out of memory' (I'm using --debug-memory) or screen corruption appears and the Spectrum crashes. I'm thinking that either I don't have enough heap or something is quietly writing over areas of memory that it shouldn't and after a while that brings the whole thing crashing down. I've tried increasing (and decreasing!) the heap space with the -H command, but it doesn't seem to make any difference.

How can I tell where the heap is located in memory, and how big it is? Is there any way to get the running program to output how much heap space it thinks is left? The heap should always be located after the compiled code in memory, right? And all string data should be in the heap? I tried compiling with the -d option but this generates tons of output, most of which I don't really understand. Smile

Does anyone have any advice on things to look for that might be causing problems like this? The program I'm working with was originally a Sinclair BASIC listing so it relies quite heavily on GO SUB/RETURN, too, so I guess it's possible that it might be nothing to do with the heap and maybe something stack-related? Grasping at straws really, I'm really just looking for a bit of advice on what I could investigate next.


Messages In This Thread

Forum Jump:

Users browsing this thread: 1 Guest(s)