想要 40 GB 内存映射文件但限制为 4 GB? vb.net
Want 40 GB Memory Mapped File but limit is 4 GB? vb.net
我 运行 遇到了 .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 构建模式时,我现在可以变得更大 spaces 但在我想要的 40 GB 时我收到一个新错误 The paging file is too small for this operation to complete.
原来我所要做的就是更改我在答案中发布的屏幕截图中默认为 800 MB 的分页文件,现在它可以正常工作了!
所以它的上限为 4 GB?这个限制可以在我的系统中的某个地方改变吗?我有超过 900 GB 的硬盘 space 可用,为什么 4 GB 的限制是我能做的还是我必须完全从基元构建文件系统才能按块读取 40 GB。
有没有通过虚拟硬盘做大内存阵列的参考资料或组件space?
下面是我的代码
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
解决了!
您需要修改虚拟内存分页文件并在构建模式下使用 x64
我 运行 遇到了 .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 构建模式时,我现在可以变得更大 spaces 但在我想要的 40 GB 时我收到一个新错误 The paging file is too small for this operation to complete.
原来我所要做的就是更改我在答案中发布的屏幕截图中默认为 800 MB 的分页文件,现在它可以正常工作了!
所以它的上限为 4 GB?这个限制可以在我的系统中的某个地方改变吗?我有超过 900 GB 的硬盘 space 可用,为什么 4 GB 的限制是我能做的还是我必须完全从基元构建文件系统才能按块读取 40 GB。
有没有通过虚拟硬盘做大内存阵列的参考资料或组件space?
下面是我的代码
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
解决了!
您需要修改虚拟内存分页文件并在构建模式下使用 x64