问题描述
我在这个地方,起动用C#移动一个新手。现在,我正在对C#手持设备平台。所以,我有一些问题想请教一下如何让内存使用情况。我已经尝试 GC.GetTotalMemory()并获得分配的内存的GC使用。但是,我可以用它来估计,有多少我的应用程序分配内存。我想,这可能是但不实际的正确。然后,我已经尝试谷歌以搜索任何参考或类或任何用于检查内存在Windows CE,但我发现只有在不支持我做的事情的另一个平台。
I'm a newbie in this place and starter with C# mobile. Now , I'm working on C# handheld device platform. So , I have some question to ask about how to get the memory usage.I have try GC.GetTotalMemory() and get the allocated memory that the GC used. But , Can I use this to estimated that how much my application was allocated the memory. I suppose that it may be but not actual correct. Then I've try google to searching for any reference or class or anything to use for checked the memory on windows CE but I've found only in another platform that not supported with the thing I'm doing.
在此先感谢,Stoper
Thanks in advance ,Stoper
道歉,我从这个职位消失。
Apologize for that I gone away from this post.
我真的很感谢你对任何人谁已经回答我的问题,看这个帖子。
I'm really thank you to anybody who've answer my question and watch on this post.
现在,我得到了所有我需要实现我的项目OpenNetCF的参考。
Now , I got all that I need by implement the "OpenNetCF" reference in my project.
再次感谢;)
推荐答案
根据文档,<$c$c>GC.GetTotalMemory$c$c>返回
According to the docs, GC.GetTotalMemory
returns
一个数字,是目前分配在托管内存字节数的最好的逼近
这是一个有点误导/混淆一些开发者,尤其是那些从本机的世界即将到来。它会告诉你多少内存的GC已分配的内部的但是不知道它的实际分配整个堆(即分配的和未分配的托管内存)的系统。
This is a bit misleading/confusing to some devs, especially those coming from a native world. It's going to tell you how much memory the GC has allocated internally but not what its actual allocation for the whole heap (i.e. allocated and unallocated managed memory) from the system is.
它也不会报告本地分配。如果你使用了很多GDI对象(位图,刷子等),为那些具有本机内存分配,以及这可能是巨大的。在一个位图的德情况下,它的管理足迹比它的本机内存占用实际上要小得多。
It also doesn't report native allocations. This can be huge if you use a lot of GDI objects (bitmaps, brushes, etc) as those have native memory allocations as well. In teh case of a Bitmap, it's managed footprint is actually much smaller than its native footprint.
如果你有兴趣在你的管理应用程序对整个系统资源的实际影响,需要查询操作系统,并询问有多少物理的和虚拟的内存它得到一个实际的感受是什么事情(我觉得GC.GetTotalMemory是其实比较没用)。你想要什么P /调用 GlobalMemoryStatus 给你。 MSDN包含一个例子。
If you're interested in your managed apps actual impact on the overall system resources, you need to query the OS and ask how much physical and virtual memory it has to get an actual feel for what's going on (I find GC.GetTotalMemory to be relatively useless in fact). P/Invoking GlobalMemoryStatus gives you what you want. MSDN contains an example.
这篇关于C#的Windows CE .NET 3.5,以检查内存使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!