How does one pre-allocate the correct amount of memory for game assets?
I have been working my way through handmade hero. I have watched the first 50 episodes and a hand full of the later episodes.
One concept that really interested me was the practice of pre-allocating all the needed memory for a game right at the start. From what I understand, Casey has basically grabbed a large chunk of memory and has used it for some of the game data and tile maps.
However, he currently(around ep 50) seems to allocate new memory every time he loads an asset file like a bitmap or such. I assume eventually this data will be will be converted to a different format and be loaded into the memory that he has pre-allocated instead of just allocating new memory. This means the pre-allocated memory would need to be large enough for the largest possible amount of assets that can be shown at once correct? How would one know how much memory to allocate? Would one try to calculate it by hand, or just play through the game with a very large memory allocation and record largest amount of memory needed during the playthrough then reduce the pre-allocation to that size. What if you missed an asset intensive event that could occur and thus have the wrong size?
Am I overthinking things? I have tried jumping around to a few episodes to find the solution, but am still confused on how one would do this. It seems like a very difficult problem to solve if a game has lot of detailed assets.
Any thoughts?