Profile memory usage for C projects in Windows Simulator

I guess this is mainly a request/question for @willco . It seems that in the Mac simulator it is possible to profile memory usage of C projects, but in Windows I can't seem to find any similar functionality. The only memory profiler I can find is Lua Memory, which does not display anything for C-only projects. Is this functionality planned for future versions of the Windows Simulator? Thanks.

2 Likes

Yes, I can look into getting it added! At this point, I'm prioritizing user requests, if you feel like it would be useful I will move it to the top of the list.

1 Like

That would be great! I do think it would be very useful, especially detecting memory leaks and determining memory usage. I also heard the Mac simulator allows you to cap the memory usage to 16MB to emulate the device limitations. As for moving it to the top of the list, I guess that depends on what else you are working on. :slight_smile:

1 Like

+1

I just ran into the Simulator crashing when trying to enable and use this feature on Windows. It would be extremely handy!

Are you running the 1.12 SDK? After you restarted the Simulator was it enabled?

Yeah, 1.12. If I enable malloc pooling, it crashes with a stack trace that looks like this

Then I basically can't use the Playdate Simulator again until I go to AppData\Local\Playdate Simulator\Playdate Simulator.ini and set MallocPoolSize back to 0

That is an odd place to crash. Does it crash immediately or when you launch your game? Does your game play sound? What version of Windows are you running? Thanks!

It crashes a few frames in. Game does play sound, I am using FilePlayer and TwoPoleFilter. Windows 10

Are you using a VBR mp3 by chance?

Also, to avoid restoring the last opened game in the Sim, you can hold shift while launching it. That will help you avoid going into the prefs to reset it if anything goes wrong. :slight_smile:

No, uncompressed 16khz 8bit mono WAV

Any chance you could work up a small test app with this file that shows the crash?

Yeah, I'll see if I can get a minimal repro together sometime this week

Well, my audio code behaves just fine with memory profiling in the simulator if I move it out of my main game and into a standalone app.

audio_crash_repro.zip (2.0 MB)

I poked at it a bit more in the context of my game, and I can get around the crash from happening if I omit the call to pd->sound->channel->addEffect(...). It seems like there may be a multi-threading issue related to channel insert effects when memory profiling is enabled. It is also weird to me that the address it's failing to call has 0x000000 as the lower part of the address... maybe an unset function offset?

2 Likes

@hunty Thanks for sample app. I built the app and ran it in the Simulator directly and couldn't reproduce the crash. Are you crashing when running it in Visual Studio?

@hunty OK, Dave looked at this and said this line:

tp->setResonance(sfx.windChannel, 0.5f);

should be:

tp->setResonance(sfx.windFilter, 0.5f);

Which should fix your crash. :crossed_fingers:

Ah man, bit of a derp that one! Hard to catch the typo in context. I'll give it a try next chance I get... I'm sure that's definitely causing unintended behavior though. Strange that it would only crash intermittently, even then only with the memory profiling enabled.

Yep, confirmed that fix worked! Thank you :slight_smile:

2 Likes