使用C#在asp.net中填充数据表时出现System.OutOfMemoryException错误 [英] getting System.OutOfMemoryException error while filling data Table in asp.net with c#

查看:104
本文介绍了使用C#在asp.net中填充数据表时出现System.OutOfMemoryException错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含3000000条记录的文本文件.阅读这些记录后,我试图将这些数据填充到数据表中.之后,我得到了System.OutOfMemoryException错误消息.
谁能给我解决这个问题的方法.

I have a text file with the 3000000 records. After reading these records I am trying to fill these data into the Data Table. And after that I am getting System.OutOfMemoryException error message.
Can anybody give me a solution for this problem.

推荐答案

您应该将应用程序转换为成批读取和处理数据(数据块).例如,处理文件的20000条记录,然后处理下一个20000,依此类推.

一次将所有这些记录读取到一个DataTable中从来不是一个好主意,几乎可以将其转换为不需要一次读取所有记录的其他解决方案.

希望这会有所帮助.
You should convert your application into reading and processing the data in batches (chunks of data). For example, process 20000 records of the file, and then the next 20000, etc.

Reading all these records at once in to a DataTable is never a good idea and can almost always be converted to an other solution that does not need to read all the records at once.

Hope this helps.


这篇关于使用C#在asp.net中填充数据表时出现System.OutOfMemoryException错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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