这是真实的陈述吗? [英] Is this a true statement?

查看:62
本文介绍了这是真实的陈述吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用Perfmon查看我的应用程序的GC句柄数量,并且

它在几个小时内保持不变,我没有问题

释放我应用中的非托管资源。这是真的吗?


我有一个耗尽内存的应用程序。在运行了几个小时之后,使用Perfmon,
中的#Bytes,所有堆都保持在2.5MB左右。 TaskMgr显示我的

进程使用~75MB并且稳步增长。如果内存不是任何.Net堆使用的,那么我就不会增加GC的数量

Handles,其中哎呀消耗的记忆力是什么?


有人可以请怜悯我,并指出我可能会对此简单解释吗?我一直在想我理解垃圾

集合的工作方式,以及从gen0到gen1到gen2的升级,但我必须是

在这里缺少一些基本的东西。


TIA,

Chris

解决方案

" Chris" <二***** @ hotmail.com>在消息中写道

新闻:-M ******************** @ giganews.com ...

如果我使用Perfmon来查看我的应用程序的GC句柄数量,并且它在几个小时内保持不变,我就没有问题在我的应用程序中释放非托管资源。真的吗?


我没有看到任何合理的方式将''GC Handles''
等同于''非托管资源''。每个人的数量一般是独立的。所以,不,你的断言不正确。

我有一个耗尽内存的应用程序。使用Perfmon后,所有堆中的#字节在运行数小时后保持在2.5MB左右。 TaskMgr显示我的
进程使用~75MB并且稳步增长。如果任何.Net堆都没有使用内存,而且我没有增加GC的数量,那就是消耗的内存?


也许你正在泄漏操作系统句柄。

有人可以请怜悯我并指出我可能对此简单的解释?我一直在想我理解垃圾收集工作的方式,以及从gen0到gen1到gen2的推广,但我必须在这里遗漏一些基本的东西。


也许你已经假设担心资源

泄漏是历史,现在GC系统就在这里。对不起

是坏消息的承载者,但是''''''''''''''''''''''''''''从您的

描述中,我可以认为您使用的是除了CLR内存以外的某种

资源,因为这很漂亮

很多只有(几乎)自动管理的资源

没有程序员的努力。


我的赌注是,当你修复这个问题时,会有一些

更多终结器,IDisposable实现和C#

''使用''结构将会到位。

TIA,
Chris



祝你好运。让我们知道你找到了什么。


-

- 拉里布拉斯菲尔德

电子邮件:做******************* **** @ hotmail.com

以上观点可能只属于我。


GC句柄没有关系对于无人管理的资源。


然而,TaskManager只显示工作集,这可能会产生误导。

换句话说它显示Windows没有内存觉得还有什么需要回收

,但这并不一定意味着它没有被你的

应用发布。

您是否注意到当您使用
最小化应用程序时,TaskManager报告的工作集会关闭?如果内存消耗继续整体上升,即使你定期最小化并恢复应用程序窗口,那么你可能不会释放非托管资源。




--BOB


" Chris" <二***** @ hotmail.com>在消息中写道

新闻:-M ******************** @ giganews.com ...

如果我使用Perfmon查看我的应用程序的GC句柄数量,

在几个小时内保持不变,我没有问题
释放不受管理我的应用中的资源。这是真的吗?

我有一个耗尽内存的应用程序。使用Perfmon后,所有堆中的#字节在运行数小时后保持在2.5MB左右。 TaskMgr显示我的
进程使用~75MB并且稳步增长。如果任何.Net堆都没有使用内存,而且我没有增加GC的数量,那就是消耗的内存在哪里?
有人可以请怜悯我并指出我可能对此有简单的解释吗?我一直在想我理解垃圾收集的方式,以及从gen0到gen1到gen2的推广,但我必须在这里遗漏一些基本的东西。

TIA,
Chris



如果托管堆没有增长(你看过LH堆!!),

内存增加是由于非托管部分的增长。

这部分进程内存由所有代码模块和数据占用,即

是:

1 - 所有加载的模块(托管和非托管DLL')

2 - 使用Marshal类非托管分配器分配的所有内存,如

Marshal.AllocHGlobal和Marshal,AllocCoTaskMem,Marshal.Copy等。

3 - 使用来自非托管代码的本机OS分配器分配的所有内存。

4 - 全部你的线程堆栈使用的内存(每个线程最多1MB)。


因此,如果您的非托管内存消耗不断增长,请检查COM互操作

泄漏或PInvoke泄漏。完成后释放COM对象。当使用PInvoke使用
时确保你不必释放非托管内存,并且不要使用PInvoke调用未记录的函数或函数。 >
分配,没有任何方法让调用者取消分配。

如果你使用Marhal类分配器,请确保在完成时释放分配的

内存。

保持线程数(手动和线程池)运行(或等待)尽可能低的b / b
,确保其中一些线程无法等待事件

不会发生。


Willy。


" Chris" <二***** @ hotmail.com>在消息中写道

新闻:-M ******************** @ giganews.com ...

如果我使用Perfmon查看我的应用程序的GC句柄数量,

在几个小时内保持不变,我没有问题
释放不受管理我的应用中的资源。这是真的吗?

我有一个耗尽内存的应用程序。使用Perfmon后,所有堆中的#字节在运行数小时后保持在2.5MB左右。 TaskMgr显示我的
进程使用~75MB并且稳步增长。如果任何.Net堆都没有使用内存,而且我没有增加GC的数量,那就是消耗的内存在哪里?
有人可以请怜悯我并指出我可能对此有简单的解释吗?我一直在想我理解垃圾收集的方式,以及从gen0到gen1到gen2的推广,但我必须在这里遗漏一些基本的东西。

TIA,
Chris



If I use Perfmon to look at the number of GC Handles for my application, and
it stays about the same over several hours, I don''t have an issue with
freeing up unmanaged resources in my app. Is that true?

I have an application that is using up memory. Using Perfmon, # Bytes in
all heaps stays around 2.5MB after running for hours. TaskMgr shows my
process to be using ~75MB and growing steadily. If the memory isn''t being
used by any of the .Net heaps, and I''m not increasing the number of GC
Handles, where the heck is the memory being consumed?

Could someone please take pity on me and point me toward the, probably
simple, explanation for this? I keep thinking I understand the way garbage
collection works, and the promotion from gen0 to gen1 to gen2, but I must be
missing something fundamental here.

TIA,
Chris

解决方案

"Chris" <di*****@hotmail.com> wrote in message
news:-M********************@giganews.com...

If I use Perfmon to look at the number of GC Handles for my application, and
it stays about the same over several hours, I don''t have an issue with
freeing up unmanaged resources in my app. Is that true?
I do not see any logical way to equate ''GC Handles''
to ''unmanaged resources''. The number of each is, in
general, independent. So, no, your assertion is not true.
I have an application that is using up memory. Using Perfmon, # Bytes in
all heaps stays around 2.5MB after running for hours. TaskMgr shows my
process to be using ~75MB and growing steadily. If the memory isn''t being
used by any of the .Net heaps, and I''m not increasing the number of GC
Handles, where the heck is the memory being consumed?
Maybe you are leaking OS handles.
Could someone please take pity on me and point me toward the, probably
simple, explanation for this? I keep thinking I understand the way garbage
collection works, and the promotion from gen0 to gen1 to gen2, but I must be
missing something fundamental here.
Perhaps you have assumed that worries about resource
leaks are history, now that a GC system is here. Sorry
to be the bearer of bad news, but ''t''aint so. From your
description, I can divine that you are using some kind of
resource other than CLR memory, since that is pretty
much the only resource that is (almost) automatically
managed without programmer effort.

My bet would be that, when you get this fixed, a few
more finalizers, IDisposable implementation, and C#
''using'' constructs will be in place.
TIA,
Chris



Good luck. Let us know what you find.

--
--Larry Brasfield
email: do***********************@hotmail.com
Above views may belong only to me.


GC Handles doesn''t relate to unamanged resources.

However, TaskManager just shows the working set, which can be misleading.
In other words it shows memory that Windows hasn''t felt any need to reclaim
as yet, but this doesn''t necessarily mean it''s not been released by your
app.

Do you notice the working set as reported by TaskManager going down when you
minimize the app? If the memory consumption continues to rise overall over
time even when you periodically minimize and restore the application window,
then you may not be releasing unmanaged resources.

--Bob

"Chris" <di*****@hotmail.com> wrote in message
news:-M********************@giganews.com...

If I use Perfmon to look at the number of GC Handles for my application,
and
it stays about the same over several hours, I don''t have an issue with
freeing up unmanaged resources in my app. Is that true?

I have an application that is using up memory. Using Perfmon, # Bytes in
all heaps stays around 2.5MB after running for hours. TaskMgr shows my
process to be using ~75MB and growing steadily. If the memory isn''t being
used by any of the .Net heaps, and I''m not increasing the number of GC
Handles, where the heck is the memory being consumed?

Could someone please take pity on me and point me toward the, probably
simple, explanation for this? I keep thinking I understand the way
garbage
collection works, and the promotion from gen0 to gen1 to gen2, but I must
be
missing something fundamental here.

TIA,
Chris



If the managed heaps are NOT growing (did you look at the LH heap!!), the
memory increase is due to the growing of the non managed portion.
This part of the process memory is taken by all code modules and data, that
is:
1 - all loaded modules (managed and unmanaged DLL''s)
2 - all memory allocated using the Marshal class unmanaged allocators like
Marshal.AllocHGlobal and Marshal,AllocCoTaskMem, Marshal.Copy etc.
3 - all memory allocated using native OS allocators from unmanaged code.
4 - all memory used by your thread stacks (up to 1MB per thread).

So if your unmanaged memory consumption keeps growing, check for COM interop
leaks or PInvoke leaks. Release your COM objects when done with it. When
using PInvoke make sure you don''t have to free unmanaged memory, and don''t
use PInvoke to call undocumented functions or functions that possibly
allocate without any means for the caller to de-allocate.
If you are using Marhal class allocators make sure you free the allocated
memory when done.
Keep the number of threads (manual and threadpool) running (or waiting) as
low as possible, make sure some of them aren''t blocked waiting for an event
that won''t happen.

Willy.


"Chris" <di*****@hotmail.com> wrote in message
news:-M********************@giganews.com...

If I use Perfmon to look at the number of GC Handles for my application,
and
it stays about the same over several hours, I don''t have an issue with
freeing up unmanaged resources in my app. Is that true?

I have an application that is using up memory. Using Perfmon, # Bytes in
all heaps stays around 2.5MB after running for hours. TaskMgr shows my
process to be using ~75MB and growing steadily. If the memory isn''t being
used by any of the .Net heaps, and I''m not increasing the number of GC
Handles, where the heck is the memory being consumed?

Could someone please take pity on me and point me toward the, probably
simple, explanation for this? I keep thinking I understand the way
garbage
collection works, and the promotion from gen0 to gen1 to gen2, but I must
be
missing something fundamental here.

TIA,
Chris



这篇关于这是真实的陈述吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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