【问题标题】:Alternate way to find memory usage of system and program查找系统和程序的内存使用情况的替代方法
【发布时间】:2011-10-15 17:33:46
【问题描述】:

我想要一个替代方法来查找总内存使用量和单个进程使用的内存,而无需在 C# 程序中使用 System.Diagnostic,因为我正在为一个设备开发 Mono 实现的应用程序,但它还没有任何 System.diagnostic 实现。

谢谢, 米兰

【问题讨论】:

    标签: c# .net memory mono memory-management


    【解决方案1】:

    您是否尝试过使用 GC 本身?

            long trackStart = System.GC.GetTotalMemory(true);
    
            //your code goes here
            byte[] testData = new byte[50000];
    
            long trackEnd = System.GC.GetTotalMemory(true);
    
            long diff = trackEnd - trackStart; //You get bytes used.. may not be exact size
    

    【讨论】:

      【解决方案2】:

      您可能会发现GC.GetTotalMemory(false) 很有用。你可以在这里阅读:

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-04-20
        • 1970-01-01
        • 2020-03-11
        • 1970-01-01
        • 2017-06-03
        • 2016-09-26
        • 1970-01-01
        相关资源
        最近更新 更多