Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Effects of running out of memory
#1
I just added another (hopefully the final!) screen to my game and after compilation it locked up at the menu screen. I suspect that this is because of a lack of memory - my compiled code is now 28932 bytes long, so starting at the default of 32768 that takes me up to 61700. The heap is 4k still, yes? So there's not actually enough space to allocate it, I suspect. Compiling with -O2 took the size down a little and allowed it to run for longer, but I was still getting lockups.

I fixed this by moving the ramtop up to 30000 and now it seems fine. However, is there any way for me to be sure that this is enough space? And is there anything I should watch out for now that I've had to use some contended memory?
Reply
#2
1) You can compile with --check-memory to check for lack of memory during runtime.
2) -O3 reduces program size
3) If you're not using intensive string management (e.g. a converstional adventure) you can reduce heap size down to 1K for example and try. (Use --heap-size flag).
Reply
#3
Thanks, boriel - I didn't know about the --check-memory option, so I'll stick that into my make file by default. And I'll give the other things a try too! :-)

If I reduced the heap size down, how would I know if I didn't have enough?
Reply
#4
Unfortunately you don't. Only when running out of memory (e.g. with --check-memory). Also remove this flag on final RELEASE, for maximum performance. There will be a get_free() or the like to get the maximum free memory (since free memory is fragmented, there are two kind of functions: one for total free mem and another for lagest available block size).
Reply
#5
Hmm.... what kind of effects should I see with the memory checking switched on, boriel?

I activated memory checking, put the start of the code back to 32768 and recompiled, but I still get the lock-up after my menu has drawn, just the same as without the flag. Moving the ramtop back to 30000 still fixes it, as does reducing the heap size to 2k instead of 4k, so I'm fairly sure it must be memory-related.

This is just a curiosity, by the way - not really a 'problem' as such. I have a lot of extra debug code in my game which I'll be removing, so I'm sure I can get a bunch of memory back quite easily. :-)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)