pj64team / Project64-Legacy

Finishing what we started.
81 stars 6 forks source link

Reduce large contiguous heap allocations #100

Closed parasyte closed 11 months ago

parasyte commented 1 year ago

We don't need to allocate space for the entire ROM. Just the 1MB (and change) needed for the CRCs.

We also do not need to allocate any memory at all for playing the ROM. We have a memory mapped file for that. The biggest chunk of this PR migrates fully to the memory mapped file with no heap allocation.   Fixes the "unable to allocate memory" error when loading Conker or RE2.

The driving factor for these changes seems to be the nvidia driver (it's 50 MB!!). The driver takes a massive contiguous block of our virtual address space, so we need to be careful about the number of large allocation blocks. The ROM file is definitely the largest contiguous block that the emulator would allocate. The next largest blocks are used for storing temporary cheat results (See #41 for background). These can also use memory mapped files if they become a problem.