Memory 在WP8的cocos2dx项目中检测内存泄漏

Memory 在WP8的cocos2dx项目中检测内存泄漏,memory,windows-phone-8,memory-leaks,cocos2d-x,Memory,Windows Phone 8,Memory Leaks,Cocos2d X,我想在适用于windows phone 8的cocos2dx应用程序中查找一些内存泄漏IDE是Visual studio express 2012。我看到了这个链接。但正如页面上所写,“只有执行选项可用于Direct3D应用程序”。由于cocos2dx在windows phone中使用directx,我无法确定内存分析的选项。如何检测内存泄漏?您可以通过以下代码检测应用程序内存使用情况。 在App.xaml.cs中添加以下代码 公共部分类应用程序:应用程序 { 现在在应用程序启动中调用Begin

我想在适用于windows phone 8的cocos2dx应用程序中查找一些内存泄漏<代码>IDE是Visual studio express 2012。我看到了这个链接。但正如页面上所写,“只有执行选项可用于Direct3D应用程序”。由于
cocos2dx
在windows phone中使用directx,我无法确定内存分析的选项。如何检测内存泄漏?

您可以通过以下代码检测应用程序内存使用情况。 在App.xaml.cs中添加以下代码

公共部分类应用程序:应用程序 {

现在在应用程序启动中调用BeginRecording()函数。
这将在每2秒后为您提供准确的内存统计信息,您可以识别内存泄漏。

我也遇到了这个问题,我的wp8 CoCoCos2D-x应用程序内存很快就用完了。。。
    private static Timer timer = null;
    public static void BeginRecording()
    {

        if (System.Diagnostics.Debugger.IsAttached)
        {
            // start a timer to report memory conditions every 2 seconds
            timer = new Timer(state =>
            {
                // every 2 seconds do something 
                string report =
                DateTime.Now.ToLongTimeString() + " memory conditions: " +
                Environment.NewLine +
                "\tApplicationCurrentMemoryUsage: " +
                    getExactValue(DeviceStatus.ApplicationCurrentMemoryUsage) + " MB" +
                    Environment.NewLine +
                "\tApplicationPeakMemoryUsage: " +
                    getExactValue(DeviceStatus.ApplicationPeakMemoryUsage) + " MB" +
                    Environment.NewLine +
                "\tApplicationMemoryUsageLimit: " +
                    getActualValue(DeviceStatus.ApplicationMemoryUsageLimit) + " MB" +
                    Environment.NewLine +
                "\tDeviceTotalMemory: " + getActualValue(DeviceStatus.DeviceTotalMemory) + " MB" + Environment.NewLine +
                "\tApplicationWorkingSetLimit: " +
                    getActualValue(Convert.ToInt64(DeviceExtendedProperties.GetValue("ApplicationWorkingSetLimit"))) + " MB" +
                    Environment.NewLine;

                // write to IsoStore or debug conolse
                Debug.WriteLine(report);
            },
            null,
            TimeSpan.FromSeconds(2),
            TimeSpan.FromSeconds(2));
        }
    }
    public static decimal getExactValue(long stats)
    {
        return Math.Round(((decimal)(stats) / (decimal)(1048576.00)), 2);
    }

    public static int getActualValue(long stats)
    {
        return ((int)Math.Ceiling(getExactValue(stats)));
    }