PLS帮助 - 强制Gobal垃圾收集 [英] PLS HELP - Forcing Gobal Garbage Collection

查看:91
本文介绍了PLS帮助 - 强制Gobal垃圾收集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我在这里遇到了一个情况:)如果有人可以帮助我,那就是dwonder。

我有一个MDI应用程序并说,孩子表单有一个按钮,点击它调用数据库

事务 - 将很多表格抓取到表单'的TDataSet变量中。一笔交易抓住了10美元或更多Mb的数据。

如果我做了几笔交易,应用程序占用的内存可以说高达180Mb - 我看着它任务管理器中的



现在我关闭子窗体,ChildForm.Dispose调用DataSet.Dispose()。没有任何事情发生,内存分配的
仍然是180 Mb。

在Parent MDI表单上,我选择了一个调用GC.Collect()的菜单选项。再一次,没有任何变化...仍然是180Mb


现在我让程序运行''空闲''(应用程序什么都不做)我开始在Excel中做一些图表和

其他项目的Word。突然在大约5分钟后我看到任务管理器和bummmm - 我的运行

应用程序现在只占用5(5 !!!)MB内存...而不是180 Mb


我意识到垃圾收集并不能立即完成工作,但只有在它认为它的时候才能完成它,但有没有办法以某种方式强制它?我们有客户抱怨说,当他们进行很多交易时,因为内存不足而导致程序崩溃。


任何建议都会受到高度赞赏!!!


谢谢,

Andrey

Hi,

I got a situation here :) an dwonder if someone can help me.
I have an MDI app and say, the child form has a button, clicking on which calls a database
transaction - grabbing a lot of tables to the form''s TDataSet variable. One transaction grabs about
10 or more Mb of data.
If i do several transactions, the memory occupied by the app goes say goes up to 180Mb - i watch it
in Task Manager.

Now i close the child form, and ChildForm.Dispose calls DataSet.Dispose(). Nothing happens, memory
allocated is still 180 Mb.
On the Parent MDI form i cick a menu option calling GC.Collect(). Again, nothing changes... still 180Mb

Now i leave the program running ''idle'' (app does nothing) and i start doing some charts in Excel and
Word for some other project. Suddenly in about 5 min i look at Task Manager and bummmm - my running
application now occupies only 5(five!!!) MB of memory... instead of 180 Mb

I realize that garbage collection doesn''t do the job right away, but only when it considers it
nessesary, but is there a way to force it somehow? We have clients complaining that program is
crashing on them because of insufficient memory when they do many transactions.

Any suggestions would be highly appreciated!!!

Thank you,
Andrey

推荐答案

" MuZZy" <乐******* @ yahoo.com>在消息中写道

news:yt ******************** @ comcast.com ...
"MuZZy" <le*******@yahoo.com> wrote in message
news:yt********************@comcast.com...
你好,
嗨。我有一个情况:)如果有人可以帮助我,那就是dwonder。
我有一个MDI应用程序说,子表单有一个按钮,点击哪个调用数据库事务 - 抓住很多表
到表格'的TDataSet变量。一个事务可以获取大约10个或更多Mb的数据。
如果我进行多次交易,应用程序占用的内存可以说高达180Mb - 我在任务管理器中观看它。

现在我关闭子窗体,ChildForm.Dispose调用DataSet.Dispose()。没有任何反应,分配的内存仍然是180 Mb。
在Parent MDI表单上,我点击了一个调用GC.Collect()的菜单选项。再一次,没有任何变化......仍然是180Mb
现在我让程序运行''空闲''(应用程序什么都不做),我开始在Excel和Word中为一些其他项目做一些图表。突然在大约5分钟内我看到任务管理器和bummmm - 我正在运行的应用程序现在只占用5(5 !!!)MB的内存......
而不是180 Mb

我意识到垃圾收集并不能立即完成工作,但只有当它认为它是必要的时候,才有办法以某种方式强制它?我们有客户抱怨程序正在崩溃,因为他们做了很多交易时内存不足。

任何建议都会受到高度赞赏!


一种方法是将您的数据请求重新修改为不会花费这么多。这将需要您的

部分更多的工作,但会提高您的应用程序的性能。你有没有试过在表格中处理10 MB的数据?
当然

没有人需要通过这一切滚动。

谢谢你,
安德烈
Hi, Hi. I got a situation here :) an dwonder if someone can help me.
I have an MDI app and say, the child form has a button, clicking on which calls a database transaction - grabbing a lot of tables
to the form''s TDataSet variable. One transaction grabs about 10 or more Mb of data.
If i do several transactions, the memory occupied by the app goes say goes up to 180Mb - i watch it in Task Manager.

Now i close the child form, and ChildForm.Dispose calls DataSet.Dispose(). Nothing happens, memory allocated is still 180 Mb.
On the Parent MDI form i cick a menu option calling GC.Collect(). Again, nothing changes... still 180Mb

Now i leave the program running ''idle'' (app does nothing) and i start doing some charts in Excel and Word for some other project.
Suddenly in about 5 min i look at Task Manager and bummmm - my running application now occupies only 5(five!!!) MB of memory...
instead of 180 Mb

I realize that garbage collection doesn''t do the job right away, but only when it considers it nessesary, but is there a way to
force it somehow? We have clients complaining that program is crashing on them because of insufficient memory when they do many
transactions.

Any suggestions would be highly appreciated!!!
One approach would be to rework your data requests to not
get so much. This would require some more work on your
part, but would improve the performance of your app. Have
you ever tried to deal with 10 MB of data in a form? Surely
nobody needs to scroll thru it all.
Thank you,
Andrey




- -

- 拉里·布拉斯菲尔德

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

以上观点可能只属于我。



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


MuZZy,


如果有客户抱怨,请查看任务

经理是你想要做的最后一件事。您可能只需将太多信息加载到本地客户端进程中,并且您应该考虑更改您的实现。


基本上,这个错误的含义是你引用了占用大量内存的对象,并以某种方式保留它们。如图所示,当系统要求时,CLR将放弃内存。


您要加载的数据集有多大?是否需要

一次保持这一切?你能否把它分解成更小的b
工作单位?这样做可能需要更多次访问数据库服务器,

但最后,我无法想象你的系统因为巨大而无法高效运行
它占用的内存量。

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


" MuZZy" <乐******* @ yahoo.com>在消息中写道

news:yt ******************** @ comcast.com ...
MuZZy,

When you have clients complaining about that, looking at the Task
Manager is the last thing that you want to do. It is possible that you are
simply loading too much information into the local client process and that
you should look into changing your implementation.

Basically, what that error means is that you have references to objects
that are taking up that much memory, and keeping them around somehow. As
you have shown, the CLR will give up memory when the system asks for it.

How large are the datasets that you are loading? Is there a need to
keep that around all at one time? Can you not break it down into smaller
units of work? Doing so will probably require more trips to the DB server,
but in the end, I can''t imagine that your system is running to efficiently
due to the immense amounts of memory it is taking up.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"MuZZy" <le*******@yahoo.com> wrote in message
news:yt********************@comcast.com...
你好,

我在这里遇到了一个情况:)如果有人可以帮助我,那就是dwonder。
我有一个MDI应用程序说,子表单有一个按钮,点击它
调用数据库事务 - 将很多表抓取到表单''的TDataSet变量中。一个事务可以获取大约10个或更多Mb的数据。
如果我进行多次交易,应用程序占用的内存可以说高达180Mb - 我在任务管理器中观看它。

现在我关闭子窗体,ChildForm.Dispose调用DataSet.Dispose()。
没有任何反应,分配的内存仍然是180 Mb。
在父MDI窗体上我点菜菜单选项调用GC.Collect的()。再一次,
没有任何变化......仍然是180Mb
现在我让程序运行''空闲''(应用程序什么都不做)我开始在Excel中做一些图表和一些其他项目的话。突然在
大约5分钟后我看着任务管理器和bummmm - 我正在运行的应用程序现在只占用5(5 !!!)MB内存......而不是180 Mb

任何建议都会受到高度赞赏!!!
<谢谢,
Andrey
Hi,

I got a situation here :) an dwonder if someone can help me.
I have an MDI app and say, the child form has a button, clicking on which
calls a database transaction - grabbing a lot of tables to the form''s
TDataSet variable. One transaction grabs about 10 or more Mb of data.
If i do several transactions, the memory occupied by the app goes say goes
up to 180Mb - i watch it in Task Manager.

Now i close the child form, and ChildForm.Dispose calls DataSet.Dispose().
Nothing happens, memory allocated is still 180 Mb.
On the Parent MDI form i cick a menu option calling GC.Collect(). Again,
nothing changes... still 180Mb

Now i leave the program running ''idle'' (app does nothing) and i start
doing some charts in Excel and Word for some other project. Suddenly in
about 5 min i look at Task Manager and bummmm - my running application now
occupies only 5(five!!!) MB of memory... instead of 180 Mb

I realize that garbage collection doesn''t do the job right away, but only
when it considers it nessesary, but is there a way to force it somehow? We
have clients complaining that program is crashing on them because of
insufficient memory when they do many transactions.

Any suggestions would be highly appreciated!!!

Thank you,
Andrey



Larry Brasfield写道:
Larry Brasfield wrote:
" MuZZy" <乐******* @ yahoo.com>在消息中写道
新闻:yt ******************** @ comcast.com ...
"MuZZy" <le*******@yahoo.com> wrote in message
news:yt********************@comcast.com...
你好,



嗨。



Hi.

我在这里遇到了一个情况:)如果有人可以帮助我,那就是dwonder。
我有一个MDI应用程序并说,子窗体有一个按钮,点击它调用数据库事务 - 抓取表格'的TDataSet变量的很多表格。一个事务可以获取大约10个或更多Mb的数据。
如果我进行多次交易,应用程序占用的内存可以说高达180Mb - 我在任务管理器中观看它。

现在我关闭子窗体,ChildForm.Dispose调用DataSet.Dispose()。没有任何反应,分配的内存仍然是180 Mb。
在Parent MDI表单上,我点击了一个调用GC.Collect()的菜单选项。再一次,没有任何变化......仍然是180Mb
现在我让程序运行''空闲''(应用程序什么都不做),我开始在Excel和Word中为一些其他项目做一些图表。突然在大约5分钟内我看到任务管理器和bummmm - 我正在运行的应用程序现在只占用5(5 !!!)MB的内存......
而不是180 Mb

我意识到垃圾收集并不能立即完成工作,但只有当它认为它是必要的时候,才有办法以某种方式强制它?我们有客户抱怨程序正在崩溃,因为他们做了很多交易时内存不足。

任何建议都会受到高度赞赏!!!
I got a situation here :) an dwonder if someone can help me.
I have an MDI app and say, the child form has a button, clicking on which calls a database transaction - grabbing a lot of tables
to the form''s TDataSet variable. One transaction grabs about 10 or more Mb of data.
If i do several transactions, the memory occupied by the app goes say goes up to 180Mb - i watch it in Task Manager.

Now i close the child form, and ChildForm.Dispose calls DataSet.Dispose(). Nothing happens, memory allocated is still 180 Mb.
On the Parent MDI form i cick a menu option calling GC.Collect(). Again, nothing changes... still 180Mb

Now i leave the program running ''idle'' (app does nothing) and i start doing some charts in Excel and Word for some other project.
Suddenly in about 5 min i look at Task Manager and bummmm - my running application now occupies only 5(five!!!) MB of memory...
instead of 180 Mb

I realize that garbage collection doesn''t do the job right away, but only when it considers it nessesary, but is there a way to
force it somehow? We have clients complaining that program is crashing on them because of insufficient memory when they do many
transactions.

Any suggestions would be highly appreciated!!!



一种方法是重新处理您的数据请求,以免获得如此多的收益。这将需要您的部分更多工作,但会提高您的应用程序的性能。您曾经尝试过处理表单中的10 MB数据吗?当然没有人需要滚动浏览所有内容。


One approach would be to rework your data requests to not
get so much. This would require some more work on your
part, but would improve the performance of your app. Have
you ever tried to deal with 10 MB of data in a form? Surely
nobody needs to scroll thru it all.




好​​吧,表单上显示的数据不是10 Mb。它存储在一个TDataSet变量中。

如果应用程序处于早期开发阶段,重写ddata请求的方法可能会有效。

现在它是'整个框架并没有办法改变架构 - 它可能需要20名程序员每年工作
a :)


我的问题更多关于如何修复我已有的东西,如何强制GC进行收集。


Andrey



Well, it''s not 10 Mb of data shown on the form. It''s stored in a TDataSet variable.
The approach to rework the ddata requests might work if the app was in the early development stage.
Now it''s the whole framework and there is no way to change the architecture - it might require about
a year of work by 20 programmers :)

My question is more about how to fix what i already have, how to force GC to do the collection.

Andrey


这篇关于PLS帮助 - 强制Gobal垃圾收集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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