可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
Does anyone know of a .NET array class/library which will page its contents out to disk?
The idea is to be able to use it as a normal array but the class uses less RAM (to avoid getting out-of-memory exceptions with more than 2GB of data). Ideally the class will implement one of:
- System.Collections.Generic.IList
- System.Collection.IList
Any ideas much appreciated!
回答1:
I haven't come across anything like that, but I guess that's because it's rarely needed. After all, a database table (in SQL Server or any other database) is in essence a disk-based array.
You could write an IList<> wrapper around a database table. Throw in some caching and you have a perfect disk-based array.
回答2:
Unless you're dealing with fixed length records (and even then there's issues) you're going to run into a lot of problems with treating 2GB of data like an array that make a lot of array uses perform horribly -
- IndexOf()
- InsertAt()
- RemoveAt()
- Sort()
Is there any reason a database wouldn't work?
回答3:
I found this solution in VB of a file-based array: http://www.vbforums.com/showthread.php?t=504649
But it seems hacky... Still looking for another implementation.