我在.NET中遇到一个问题,我的阵列仅限于我拥有的RAM数量,并且我需要至少可以容纳40 GB字节的阵列。。我在考虑使用硬盘驱动器作为虚拟阵列的想法不在乎它是否慢。
我正在研究这个想法,后来来到VB.net上的MemoryMappedFile
Dim mmF As MemoryMappedFile
mmF = MemoryMappedFile.CreateOrOpen("MemArray", 4294967295)
可以创建一个4 GB的阵列,但是当我尝试多一个字节4294967296
我得到了错误
'The capacity cannot be greater than the size of the system's logical address space.
Parameter name: capacity'
这是64位系统,当我从x86构建模式切换到x64构建模式时,我现在可以获得更大的空间,但是在我想要的40 GB上,我得到了一个新错误The paging file is too small for this operation to complete.
原来我要做的就是更改页面文件,该页面文件在我在答案中发布的屏幕截图中默认为800 MB,并且现在可以正常使用!
那么它的上限是4 GB?这个限制有可能在我的系统中的某个地方更改吗?我有超过900 GB的可用硬盘空间,为什么4 GB的限制是我无能为力,或者我必须完全从基元构建文件系统才能读取40 GB的块。
是否存在通过虚拟硬盘空间进行大内存阵列的引用或组件?
这是我的下面的代码
Public Function GetRotation(Data As Byte(), rotation As UInteger) As Byte()
'This works for very big numbers at very fast speeds.
'This cycle rotates the values without looping array.
Dim rotationData As New List(Of Byte)
Dim start As UInteger = Data.Length - rotation Mod Data.Length
For i = 0 To Data.Length - 1
rotationData.Add(Data((start + i) Mod (Data.Length)))
Next
Return rotationData.ToArray()
End Function
Public Function SortLexicoGraphicallyArrayMappedFile(ByRef data As Byte()) As UInteger()
Dim OrderedRotations As New List(Of UInteger)
Dim rotatedData As Byte()
Dim rotation As UInteger = 0
Dim mmF As MemoryMappedFile
'mmF.
mmF = MemoryMappedFile.CreateOrOpen("MemArray", 4294967295) 'CLng(data.LongLength * data.LongLength))
Dim mmVA As MemoryMappedViewAccessor
mmVA = mmF.CreateViewAccessor(0, data.LongLength * data.LongLength)
Dim pos As Long = 0
For rotation = 0 To data.Length - 1
rotatedData = GetRotation(data, rotation)
mmVA.WriteArray(Of Byte)(pos, rotatedData, 0, rotatedData.Length)
pos += rotatedData.LongLength
Next
'TODO later sorting them
Return OrderedRotations.ToArray()
End Function