I took this week to work on refactoring the game’s memory management. It’s not that it needed it, I’m pretty sure that I could do all the worst practices and the game would still run fine. But I did it as a learning exercise.
What Changed?
- The game now minimizes the use of
malloc
andfree
, reducing dynamic allocations wherever possible. - The only systems that still use dynamic allocation are:
- Game data loading (loading assets and initial world setup)
- Saving and loading the game state
- Managing the game state during runtime
While this is not visible to the players, it does helps me with development since now I have less allocations to track whenever I find a memory leak or other type of error.
This week’s video
What’s Next?
Next week, I’ll return to working on town mechanics, including:
- NPC Dialogue System
- Merchants Buying & Selling Goods
- Bribing Guards to Remove Bounty
Thanks for sticking with me through this behind-the-scenes update! Optimizing memory may not be flashy, but I still had a lot of fun working on it. See you next week for more exciting features!
Leave a Reply