C#字典 - 如何解决项目数限制? [英] C# dictionary - how to solve limit on number of items?

查看:128
本文介绍了C#字典 - 如何解决项目数限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的字典,我需要存储在其近13 000 000项。可惜的是,增加11 950万分之一键后,我得到了一个异常系统内存不足。是否有这个问题的任何解决方案?我需要我的程序运行就少powerable电脑比实际矿是未来..

I am using Dictionary and I need to store almost 13 000 000 keys in it. Unfortunatelly, after adding 11 950 000th key I got an exception "System out of memory". Is there any solution of this problem? I will need my program to run on less powerable computers than is actually mine in the future..

我需要很多键,因为我需要存储对 - 序列名称,序列长度,它是解决相关问题的生物信息。

I need that many keys because I need to store pairs - sequence name and sequence length, it is for solving bioinformatics related problem.

任何帮助将不胜感激。

推荐答案

购买更多的内存,安装操作系统的64位版本并重新编译为64位。不,我不是在开玩笑。如果你想这么多的对象......在RAM中......然后把它叫做一个功能。如果新的Andr​​oid可能需要16GB的内存进行编译...

Buy more memory, install a 64 bit version of the OS and recompile for 64 bits. No, I'm not kidding. If you want so many objects... in ram... And then call it a "feature". If the new Android can require 16gb of memory to be compiled...

我忘了...你可以开始阅读的C#阵,寻找更好的方法

I was forgetting... You could begin by reading C# array of objects, very large, looking for a better way

您知道有多少13亿个对象?

做一个比较,一个32位的Windows应用程序访问低于2 GB的地址空间。因此,它的2个十亿字节(给予或采取)... 2十亿/ 13000000 =东西约150字节/对象。现在,如果我们考虑引用类型多少占有...这是很容易吃150字节

To make a comparison, a 32 bits Windows app has access to less than 2 gb of address space. So it's 2 billion bytes (give or take)... 2 billion / 13 million = something around 150 bytes/object. Now, if we consider how much a reference type occupies... It's quite easy to eat 150 bytes.

我来补充一下:我看了我的魔术8球,它告诉我:告诉我们您的代码即可。如果你不告诉我们你所使用的密钥和价值观,我们应该如何能帮助你吗?你在使用,结构或原始类型?告诉我们的大小 TKEY的 TValue 。可悲的是我们的水晶球昨天打破了: - )

I'll add something: I've looked in my Magic 8-Ball and it told me: show us your code. If you don't tell us what you are using for the key and the values, how should we be able to help you? What are you using, class or struct or "primitive" types? Tell us the "size" of your TKey and TValue. Sadly our crystall ball broke yesterday :-)

这篇关于C#字典 - 如何解决项目数限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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