问题描述
大家好,
我正在处理一个令人困惑的Windows服务问题。
基本上,我使用类型化数据集将大量行
插入到SQL Server 2005数据库中。但是,调用数据适配器更新方法的内存泄漏似乎与
有关。它正在制作
内存使用情况通过屋顶,最终服务在内存不足后崩溃了
。
我用过.net内存分析器分析服务。它告诉我
有大量无关的
@ List< SQLParamter> .Enumeration @ objects。我猜这是件坏事。
我不知道怎么办。据我所知,数据集
表适配器应该在方法结束后自行清理。
如果它有帮助,我的样本代码将
....开始一个foreach循环
currentRow = tblActiveMessages.NewActiveMessagesRow();
currentRow.DownloadID = currentMessage.ID;
currentRow.TTUReference = currentMessage.VehicleID;
....分配更多属性
tblActiveMessages.Rows.Add(currentRow);
....用于循环结束
da .Update(tblActiveMessages);
我已经尝试在数据表和
表适配器周围放置一个using语句,但它绝对没有效果。
任何人都可以告诉我我能做些什么来摆脱这些小虫子!
真诚地感谢任何可以提供帮助的人 - 甚至一点点! :-(
Simon
Hi all,
I''m having a baffling problem with a windows service that I''m working on.
Basically, I am using a typed dataset to insert a large number of rows
into an SQL Server 2005 database. But there''s a memory leak that seems
to be to do with calling the data adapters update method. It''s making
the memory usage go through the roof and ultimately the service crashes
after running out of memory.
I''ve used ".net memory profiler" to analyse the service. It tells me
that there are huge numbers of undisposed
@List<SQLParamter>.Enumeration@ objects. I''m guessing this is a bad thing.
I don''t know what to do about it though. As far as I know, the dataset
table adapter should be cleaning up after itself once the method ends.
In case it helps, a sample of my code would
.... Start a foreach loop
currentRow = tblActiveMessages.NewActiveMessagesRow();
currentRow.DownloadID = currentMessage.ID;
currentRow.TTUReference = currentMessage.VehicleID;
.... Assign more properties
tblActiveMessages.Rows.Add(currentRow);
.... For loop ends
da.Update(tblActiveMessages);
I''ve tried putting a using statement around both the data table and the
table adapter, but it had absolutely no effect.
Can anyone advise me on what I can do to get rid of these little buggers!
Sincerest thanks to anyone who can help - even a little bit! :-(
Simon
推荐答案
这篇关于使用类型数据集的紧急内存泄漏问题。请帮忙! :-(的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!