处理一个物体 [英] disposing of an object

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

问题描述

我在整个应用程序中使用第三方网格。每次打开其中一个网格时,我的客户都会失去内存
。每次窗口关闭时,我都会调用

me.c1truedbgrid.dispose()

,但内存未释放。有没有其他的东西我应该做些什么来处理这个对象并回收

丢失的内存?我已经联系过c1但尚无回答。


感谢您的帮助。


Bernie Yaeger

解决方案

如果这个第三方控件是COM对象,那么是的,你必须调用:


Marshall.RealeaseCOMObject(obj)

" Bernie Yaeger" <是***** @ optonline.net>在消息中写道

新闻:%2 **************** @ TK2MSFTNGP10.phx.gbl ...

我用我的应用程序中的第三方网格。我的客户每次打开其中一个网格时都会失去记忆。每次窗口关闭时我都会调用
me.c1truedbgrid.dispose()
但内存不会被释放。是否有其他我应该做的事情来处理这个对象并回收遗失的内存?我已经联系过c1但尚无答案。

感谢您的帮助。

Bernie Yaeger



Bernie,


Dispose永远不会释放内存。


它唯一能做的就是给GC你认为它可以发布的信号是b $ b。但是,GC会再次检查,如果它不能发布,那么它会停止。


最后一个的原因可以是对现有的参考对象或来自现有对象的

引用。

Cor


" Bernie Yaeger" <是***** @ optonline.net> schrieb:

我在我的应用程序中使用第三方网格。我的客户每次打开其中一个网格时都会失去记忆。每次窗口关闭时我都会调用
me.c1truedbgrid.dispose()
但内存不会被释放。是否有其他我应该做的事情来处理这个对象并回收遗失的内存?我已经联系过c1,但还没有给他们回答。




这是一个.NET控件还是一个ActiveX控件?除此之外,您可能需要使用内存分析器来检查进程占用的内存是否真正用于任务管理器中显示的内存。查看

''GC.WaitForPendingFinalizers''+''GC.Collect''也用于调试目的。


Allocation Profiler src

< URL:http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid = 3254325d-a4aa-4bb3-aa86-c72d5104ec74>


CLR .NET Framework 2.0的Profiler

< URL:http://www.microsoft.com/downloads/details.aspx?familyid = a362781c-3870-43be-8926-862b40aa0cd0& displaylang = en> ;


CLR Profiler(v2.0)

< URL:http://www.microsoft.com/downloads/details.aspx?FamilyId = 86CE6052-D7F4-4AEB-9B7A-94635BEEBDDA& displaylang = zh>


-

MS Herfried K. Wagner

MVP < URL:http://dotnet.mvps.org/>

VB< URL:http://classicvb.org/petition/>


I use a 3rd party grid throughout my apps. My customers are losing memory
each time they open one of the grids. I call
me.c1truedbgrid.dispose()
each time the window closes, but the memory is not released. Is there
something else I should be doing to dispose of this object and reclaim the
lost memory? I''ve contacted c1 but no answer from them yet.

Thanks for any help.

Bernie Yaeger

解决方案

If this 3rd party control is a COM object, then yes, you must call:

Marshall.RealeaseCOMObject(obj)
"Bernie Yaeger" <be*****@optonline.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...

I use a 3rd party grid throughout my apps. My customers are losing memory
each time they open one of the grids. I call
me.c1truedbgrid.dispose()
each time the window closes, but the memory is not released. Is there
something else I should be doing to dispose of this object and reclaim the
lost memory? I''ve contacted c1 but no answer from them yet.

Thanks for any help.

Bernie Yaeger



Bernie,

Dispose does never release memory.

The only thing it does is giving the GC a signal that it in your opinion can
be released. However, the GC will check for that again and if it can not be
released it stays.

Reasons for the last can be a reference to an existing object or an
reference from an existing object.

Cor


"Bernie Yaeger" <be*****@optonline.net> schrieb:

I use a 3rd party grid throughout my apps. My customers are losing memory
each time they open one of the grids. I call
me.c1truedbgrid.dispose()
each time the window closes, but the memory is not released. Is there
something else I should be doing to dispose of this object and reclaim the
lost memory? I''ve contacted c1 but no answer from them yet.



Is this a .NET control or an ActiveX control? In addition to that you may
want to use a memory profiler to check if the memory occupied by the process
as shown in task manager is really used. Check out
''GC.WaitForPendingFinalizers'' + ''GC.Collect'' for debugging purposes too.

Allocation Profiler src
<URL:http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=3254325d-a4aa-4bb3-aa86-c72d5104ec74>

CLR Profiler for the .NET Framework 2.0
<URL:http://www.microsoft.com/downloads/details.aspx?familyid=a362781c-3870-43be-8926-862b40aa0cd0&displaylang=en>

CLR Profiler (v2.0)
<URL:http://www.microsoft.com/downloads/details.aspx?FamilyId=86CE6052-D7F4-4AEB-9B7A-94635BEEBDDA&displaylang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


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

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