I've been debugging a weird memory leak bug in Mario Kart Wii (unrelated to Dolphin) over the last couple days that we've ran into while developing a new feature for Wiimmfi. In order to debug this more efficiently, I need to make sure that the game's internal "malloc" methods never run out of space and always return valid memory, so I would like to use Dolphin to give the game access to more RAM to do that.
More context: I have been unable to figure out which exact code is responsible for the memory leak, but I noticed that there's like a dozen different malloc-like functions in the game, each used by various "subsystems". If II could go through these, one-by-one, and make them allocate RAM from elsewhere (no longer using "main" memory), I could figure out which of the malloc functions is the culprit (the one where the leak stops when it's allocating from elsewhere).
I saw in the code that Dolphin seems to have a code path to emulate a development console instead of a retail one to have more RAM, but I don't think that that is going to help me. That will increase the size of the main mem90 range, but all the internal heaps the game creates will still have their original size. As this is purely for testing and not something that will ever run in production, I had the crazy idea of "inventing" my own memory range.
Is it possible to mod Dolphin to just consider like the range between 0x50000000 and 0x7fffffff to be valid memory, without assigning it to either mem80 or mem90? So that a stock unmodified game will never read or write to that RAM on its own, but custom game patches / code can read and write (execute would be cool, but isn't required) from and to this memory block?
Then I could, one-by-one, patch the game's malloc methods to just always return space from that range (and maybe I don't even need to bother freeing anything and can just return new space every time), and once I notice that the game's actual RAM usage in mem80 and mem90 is no longer leaking / uselessly increasing, I know that the malloc function I'm currently "redirecting" to the new is responsible for the memory leak, and I at least have less code to analyze for memory leaks. The game doesn't have any checks on the return value of malloc (except checking if it's 0), so it should handle nonstandard addresses just fine, I hope.
I assume that since the games all implement memory management, heaps, malloc/free, ... themselves there's probably no feature in Dolphin to help debug memory leaks either, is there? Or any other feature that would help in this case?
More context: I have been unable to figure out which exact code is responsible for the memory leak, but I noticed that there's like a dozen different malloc-like functions in the game, each used by various "subsystems". If II could go through these, one-by-one, and make them allocate RAM from elsewhere (no longer using "main" memory), I could figure out which of the malloc functions is the culprit (the one where the leak stops when it's allocating from elsewhere).
I saw in the code that Dolphin seems to have a code path to emulate a development console instead of a retail one to have more RAM, but I don't think that that is going to help me. That will increase the size of the main mem90 range, but all the internal heaps the game creates will still have their original size. As this is purely for testing and not something that will ever run in production, I had the crazy idea of "inventing" my own memory range.
Is it possible to mod Dolphin to just consider like the range between 0x50000000 and 0x7fffffff to be valid memory, without assigning it to either mem80 or mem90? So that a stock unmodified game will never read or write to that RAM on its own, but custom game patches / code can read and write (execute would be cool, but isn't required) from and to this memory block?
Then I could, one-by-one, patch the game's malloc methods to just always return space from that range (and maybe I don't even need to bother freeing anything and can just return new space every time), and once I notice that the game's actual RAM usage in mem80 and mem90 is no longer leaking / uselessly increasing, I know that the malloc function I'm currently "redirecting" to the new is responsible for the memory leak, and I at least have less code to analyze for memory leaks. The game doesn't have any checks on the return value of malloc (except checking if it's 0), so it should handle nonstandard addresses just fine, I hope.
I assume that since the games all implement memory management, heaps, malloc/free, ... themselves there's probably no feature in Dolphin to help debug memory leaks either, is there? Or any other feature that would help in this case?