OpenSWE1R / openswe1r

An Open-Source port of the 1999 Game "Star Wars Episode 1: Racer"
https://openswe1r.github.io/
GNU General Public License v2.0
312 stars 26 forks source link

Lower memory consumption #178

Closed JayFoxRox closed 4 years ago

JayFoxRox commented 5 years ago

A couple of changes intended to avoid high memory consumption.

An important change is the reuse of file handles, by scanning over all handle slots to find a free one. The assumption is that there'll be very few handles at all time (I've seen 4 at most), so the allocation should be fast.

Another critical change is the use of a fixed-size block allocator for the heap. It's working similar to the file allocator, but using a bitmap for tracking wether blocks are used or not; however, this will be slow and wasteful. As-is, it will consume about the same memory as before (possibly more), and it will be slower. This can be tolerated, as future changes (another allocator + free'ing memory) will bring back performance and reduce memory usage significantly.