如何获取应用程序使用的内存量 [英] How to get the amount of memory used by an application

查看:94
本文介绍了如何获取应用程序使用的内存量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
如何获取可用的内存或在C#中使用内存

我想在应用程序的状态栏中显示应用程序使用的内存.我正在寻找内存泄漏-但我不知道在哪里.现在,我的想法是在状态栏中可视化已使用的内存,以便在使用应用程序时可以看到它,并找到发生问题的位置,然后对此进行性能分析.

有人可以给我些帮助吗,我如何获得用过的内存.

解决方案

您可以使用以下函数(true参数告诉GC首先执行收集):

long memory = GC.GetTotalMemory(true);

Possible Duplicate:
How to get memory available or used in C#

I want to visualize the memory which is used by my application in the statusbar of my application. I am searching for a memoryleak - but I don't know where. Now, my idea is to visualize the used memory in the statusbar so that I can see it while I am working with the application and find the part, where the problem occurs and then I can profiling this.

Can someone give me some help, how can I get the used memory.

解决方案

You can use the following function (The true parameter tells the GC to perform a collection first):

long memory = GC.GetTotalMemory(true);

这篇关于如何获取应用程序使用的内存量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆