内存清理 [英] Memory Cleanup

查看:60
本文介绍了内存清理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试追踪引用对象的位置,因为我想在完成它们之后清理内存
。我以为我找到了所有

引用,但它看起来并不是这样,因为调用GC.Collect()并不是非常免费的



我运行了内置的分析器并收到警告:

"第2代收集了异常百分比的对象,这是

效率低下。使用Objects Lifetime视图进一步调查。


前三代2是:

System.Decimal

系统.Int32

System.Runtime.Serialization.ObjectHolder


我不认为我能做些什么关于Decimal和Int32但是什么

是ObjectHolder?我做反序列化数据,但不知道我能做些什么

清理这个对象


谢谢,

Joe

I''m trying to track down where objects are referenced because I want to
clean up the memory when I''m done with them. I thought I found all
references but it doesn''t seem that way because calling GC.Collect() doesn''t
free very much.

I ran the built-in profiler and I get a warning:
"An abnormal percentage of objects were collected in generation 2, which is
inefficient. Investigate further by using the Objects Lifetime view."

The top 3 generation 2 are:
System.Decimal
System.Int32
System.Runtime.Serialization.ObjectHolder

I don''t think there is anything I could do about Decimal and Int32 but what
is the ObjectHolder? I do deserialize data but don''t know what I can do to
clean up this object

Thanks,
Joe

推荐答案

1)一般不建议以编程方式调用GC.Collect,最好让

运行时确定最佳时间。

2)作为跟踪内存耗尽的跟踪的一部分,你可能想要在完成后将你的主要类型设置为null,并调用dispose /和设置为

null您不再使用的所有对象。在明确调用dispose之前。


祝你好运


" Joe"写道:
1) Not generally recomended to call GC.Collect programatically, better to let
runtime determine whens the best time.
2) As part of your trace to see where the memory hog is, you may want to set
your primative types to null when done, and calling dispose/and setting to
null all object you are no longer using. Before explicitly calling dispose.

Best of luck

"Joe" wrote:

我正在尝试追踪引用对象的位置,因为我想

清理内存时我''我们完成了他们。我以为我找到了所有

引用,但它看起来并不是这样,因为调用GC.Collect()并不是非常免费的



我运行了内置的分析器并收到警告:

"第2代收集了异常百分比的对象,这是

效率低下。使用Objects Lifetime视图进一步调查。


前三代2是:

System.Decimal

系统.Int32

System.Runtime.Serialization.ObjectHolder


我不认为我能做些什么关于Decimal和Int32但是什么

是ObjectHolder?我做反序列化数据,但不知道我能做些什么

清理这个对象


谢谢,

Joe
I''m trying to track down where objects are referenced because I want to
clean up the memory when I''m done with them. I thought I found all
references but it doesn''t seem that way because calling GC.Collect() doesn''t
free very much.

I ran the built-in profiler and I get a warning:
"An abnormal percentage of objects were collected in generation 2, which is
inefficient. Investigate further by using the Objects Lifetime view."

The top 3 generation 2 are:
System.Decimal
System.Int32
System.Runtime.Serialization.ObjectHolder

I don''t think there is anything I could do about Decimal and Int32 but what
is the ObjectHolder? I do deserialize data but don''t know what I can do to
clean up this object

Thanks,
Joe


正如MMA所说,您通常不会调用GC.Collect。内存被清理

需要时。


十进制和Int32都是结构,并且只分配为

对象时他们是盒装的。这表明你的程序从很多拳击中受到了



Joe写道:
As MMA said, you normally never call GC.Collect. Memory is cleaned up
when needed.

The Decimal and Int32 are both structures, and are only allocated as
objects when they are boxed. That suggests that your program suffers
from a lot of boxing.

Joe wrote:

我正在尝试追踪引用对象的位置,因为我想在我完成它们时清理内存
。我以为我找到了所有

引用,但它看起来并不是这样,因为调用GC.Collect()并不是非常免费的



我运行了内置的分析器并收到警告:

"第2代收集了异常百分比的对象,这是

效率低下。使用Objects Lifetime视图进一步调查。


前三代2是:

System.Decimal

系统.Int32

System.Runtime.Serialization.ObjectHolder


我不认为我能做些什么关于Decimal和Int32但是什么

是ObjectHolder?我做反序列化数据,但不知道我能做些什么

清理这个对象


谢谢,

Joe

I''m trying to track down where objects are referenced because I want to
clean up the memory when I''m done with them. I thought I found all
references but it doesn''t seem that way because calling GC.Collect() doesn''t
free very much.

I ran the built-in profiler and I get a warning:
"An abnormal percentage of objects were collected in generation 2, which is
inefficient. Investigate further by using the Objects Lifetime view."

The top 3 generation 2 are:
System.Decimal
System.Int32
System.Runtime.Serialization.ObjectHolder

I don''t think there is anything I could do about Decimal and Int32 but what
is the ObjectHolder? I do deserialize data but don''t know what I can do to
clean up this object

Thanks,
Joe


我调用了GC.Collect(),因为内存没有像我需要的那样快速释放到

是。我已经完成了将对象设置为null但是如果那个

对象仍在其他地方被引用,则将原始对象设置为

null将不会导致它被释放了。

我最好的猜测是在某个地方仍然有对这些对象的引用

并没有设置为null我无法找到它没有在整个应用程序中跟踪

对象。

" MMA" < MM*@discussions.microsoft.com写信息

新闻:F3 *************************** ******* @ microsof t.com ...
I call GC.Collect() because memory is not freed as quickly as I need it to
be. I already set my objects to null when I''m done with them but if that
object is still referenced somewhere else, setting the original object to
null will not cause it to be freed.
My best guess is that there is still a reference to these objects somewhere
that wasn''t set to null and I have no way of find it without tracing the
object through the entire application.
"MMA" <MM*@discussions.microsoft.comwrote in message
news:F3**********************************@microsof t.com...

1)通常不建议以编程方式调用GC.Collect,最好是



运行时间确定最佳时间。

2)作为追踪记忆力的地方的一部分,你可能想要

设置

你的主要类型在完成后为null,并调用dispose /并设置为

null所有不再使用的对象。在明确致电之前

dispose。


祝你好运


" Joe"写道:
1) Not generally recomended to call GC.Collect programatically, better to
let
runtime determine whens the best time.
2) As part of your trace to see where the memory hog is, you may want to
set
your primative types to null when done, and calling dispose/and setting to
null all object you are no longer using. Before explicitly calling
dispose.

Best of luck

"Joe" wrote:

>我正在尝试追踪对象的引用位置,因为我想在完成后清理内存跟他们。我以为我找到了所有
引用,但它看起来并不是那样,因为调用GC.Collect()
并不是很自由。

我运行内置的分析器,我收到一个警告:
第2代收集了异常百分比的对象,这对于效率低下。使用Objects Lifetime视图进一步调查。

前三代2是:
System.Decimal
System.Int32
System.Runtime.Serialization。 ObjectHolder

我认为我无法做任何关于Decimal和Int32的事情,但
是什么
是ObjectHolder?我做了反序列化数据,但不知道我能做什么
来清理这个对象

谢谢,
Joe
>I''m trying to track down where objects are referenced because I want to
clean up the memory when I''m done with them. I thought I found all
references but it doesn''t seem that way because calling GC.Collect()
doesn''t
free very much.

I ran the built-in profiler and I get a warning:
"An abnormal percentage of objects were collected in generation 2, which
is
inefficient. Investigate further by using the Objects Lifetime view."

The top 3 generation 2 are:
System.Decimal
System.Int32
System.Runtime.Serialization.ObjectHolder

I don''t think there is anything I could do about Decimal and Int32 but
what
is the ObjectHolder? I do deserialize data but don''t know what I can do
to
clean up this object

Thanks,
Joe



这篇关于内存清理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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