简体   繁体   中英

Finding memory leaks in a managed Win8 metro app?

I'm currently working on a metro game for Windows 8 using C# and SharpDX. The project is going well, but recently there's been a need to start tracking down memory leaks and I'm not really sure where to begin.

The built in memory profiler in Visual Studio 11 doesn't work for metro apps yet, WinDBG can't seem to connect to metro apps (unless I'm using it incorrectly), and I'm having a hard time finding any information about looking at managed allocations in .NET 4.5 for metro.

Does anyone have any experience with this? Is there a good place to start looking? Has anyone had success with tools to help detect memory leaks in metro apps?

Looks like I could actually use WinDbg, it just wasn't working with invasive mode. My fault.

I would, at least for now, assume that the memory leaks are not caused by Metro or SharpDX.

Check this out: Memory Leaks C#

(Or just search SO for "C# memory leaks".)

Once you go through the checklist of things gleaned from the above link/search query, then move onto checking the code related to SharpDX/Metro. The best guidelines came from my mom when I was young: "Clean up after yourself when you're done playing." Dispose of objects when you're done with them, don't leave DB, file or memory streams open for longer than you need them to be. This is the cause for many people's memory leak issues, mine included.

I suggest you use this http://msdn.microsoft.com/en-us/magazine/jj721593.aspx . There is a lot of explanations about memory leak.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM