Finding memory leaks in a managed Win8 metro app?

馋奶兔 提交于 2019-12-07 02:41:13

问题


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?


回答1:


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




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/9995164/finding-memory-leaks-in-a-managed-win8-metro-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!