创建列表< struct> [英] creating a list<struct>

查看:131
本文介绍了创建列表< struct>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码要将数据表数据保存到列表中我在数据表中有100万条记录但在524288行之后我得到此错误mscorlib.dll中出现类型System.OutOfMemoryException的异常但未处理用户代码如何解决?

谢谢

I have the below code To save data table data in to list I have 1 million records in datatable but after 524288 row I get this error An exception of type 'System.OutOfMemoryException' occurred in mscorlib.dll but was not handled in user code how can I resolve it?
thanks

推荐答案

引用:

我有以下代码

什么代码?



内存 - 本质上是有限的!

在问自己如何填写包含100万条记录的列表之前,请问自己:我将如何处理该列表?...

呈现给最终用户?没有任何用户可以处理100万个项目的列表?

保存到其他媒体(磁盘?DB?)。做它块/页面,这将为你节省一些内存...

What code?

Memory - by its nature - is limited!
Before you ask yourself how to fill a list with 1 million records, ask yourself: 'what will I do with that list?'...
Present to the end user? No way any user can handle a list of 1 million items?
Save onto some other media (disk? DB?). Do it bu chunks/pages, that will save some memory for you...


如错误所示,你的内存不足。



解决方案是:

a)使用较小的数据集(过滤)

b)部分保存,首先列出并保存10万个,再拿10万个等等b $ bc)重新设计,这样你只需要在内存中保存单页数据,其余的从存储库(数据库)中根据需要调用/>
d)增加进程可用的内存:)
AS the error says, you ran out of memory.

The solution is:
a) use smaller set of data (filtering)
b) save it partially, take first 100 000 to list and save, take another 100 000 etc
c) redesign so that you only keep single page of data in memory, the rest is called as needed from the depository (database)
d) increase the memory available to the process :)


这篇关于创建列表< struct>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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