使用类型数据集的紧急内存泄漏问题。请帮忙! :-( [英] Urgent Memory Leak Problem Using Type Dataset. Please help! :-(

查看:75
本文介绍了使用类型数据集的紧急内存泄漏问题。请帮忙! :-(的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我正在处理一个令人困惑的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

推荐答案




如果您正在使用Visual Studio 2005并插入许多记录,请查看SqlBulkCopy




否则您可以尝试批量提交数据。


问候,


Wiebe Tijsma


HSimon schreef:
Hi,

If you''re using Visual Studio 2005 and inserting many records, have a
look at SqlBulkCopy.

Otherwise you could try submitting your data in batches.

Regards,

Wiebe Tijsma

HSimon schreef:

大家好,


我正在处理一个令人困惑的Windows服务问题。


基本上,我使用一个类型化的数据集将大量的行

插入到SQL Server 2005数据库中。但是有一个内存泄漏似乎是

与调用数据适配器更新方法有关。它正在制作

内存使用情况通过屋顶最终服务崩溃

之后内存耗尽。


我用.net内存分析器来分析t它服务。它告诉我

有大量不透明的

@ 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


你在da.Update()之后正在做da.AcceptChanges() ?


有时,在COM互操作中,框架没有足够快地调用终结器

并且可能导致OOM错误。

如果其他一切都失败了,你可以在da.Update()之后检查

以后的调用是否能让它更好用:


GC.Collect();

GC.WaitForPendingFinalizers();

GC.Collect();


这个用于开发代码只是为了检查是否存在问题在那里..


" Simon"< si *** @ nothanks.comha scritto nel messaggio

news:ea ****** ******** @ TK2MSFTNGP05.phx.gbl ...
You are doing da.AcceptChanges() after the da.Update()?

Sometimes, within the COM interop, the framework is not calling finalizers
fast enough and could result OOM errors.
If everything else fails, you might check if, after da.Update() the
following calls make it work better:

GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();

This for dev code just to check if the problem is there..

"Simon" <si***@nothanks.comha scritto nel messaggio
news:ea**************@TK2MSFTNGP05.phx.gbl...

大家好,


我'我正在处理一个令人困惑的Windows服务问题。


基本上,我使用的是一个类型化的数据集来插入大量的行

进入SQL Server 2005 d atabase。但是,有一个内存泄漏似乎与调用数据适配器更新方法有关。它使得内存使用量达到了顶部,最终服务在内存耗尽之后崩溃了。


我用过.net内存分析器分析服务。它告诉我

有大量未消息的@ List< SQLParamter> .Enumeration @

对象。我猜这是件坏事。


我不知道怎么办。据我所知,数据集

表适配器应该在方法结束后自行清理。


如果它有帮助,我的样本代码将


...开始一个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



Simon


我同意另一张海报,使用某种批量插页。在Oracle中,我们得到了

28倍于适配器源代码更新的性能,我想你会得到

在SQL Server中类似的东西但是如果你不能通过更改UpdateBatchSize

属性来ñ
从中获得更多性能DataAdapter。


Glenn


" Simon"< si *** @ nothanks.comwrote in message

新闻:ea ************** @ TK2MSFTNGP05.phx.gbl ...
Simon

I agree with another poster, use some kind of bulk insert. In Oracle we get
28 times the performance of an adapter sourced update and I guess you''d get
something similiar in SQL Server But if you can''t you may be able to
squeeze a bit more performance out of it by changing the UpdateBatchSize
property of the DataAdapter.

Glenn

"Simon" <si***@nothanks.comwrote in message
news:ea**************@TK2MSFTNGP05.phx.gbl...

大家好,


我正在处理我正在处理的Windows服务的一个令人困惑的问题。


基本上,我使用的是类型化数据集来插入大量的行

进入一个SQL Server 2005数据库。但是有一个内存泄漏似乎是b / b
做机智h调用数据适配器更新方法。它使得内存使用量达到了顶部,最终服务在内存耗尽之后崩溃了。


我用过.net内存分析器分析服务。它告诉我

有大量未消息的@ List< SQLParamter> .Enumeration @

对象。我猜这是件坏事。


我不知道怎么办。据我所知,数据集

表适配器应该在方法结束后自行清理。


如果它有帮助,我的样本代码将


...开始一个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



这篇关于使用类型数据集的紧急内存泄漏问题。请帮忙! :-(的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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