您好我的.net进程出现问题,在创建内存映射文件时抛出以下异常,
System.IO.IOException: The paging file is too small for this operation to complete.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateCore(SafeFileHandle fileHandle, String mapName, HandleInheritability inheritability, MemoryMappedFileSecurity memoryMappedFileSecurity, MemoryMappedFileAccess access, MemoryMappedFileOptions options, Int64 capacity)
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateNew(String mapName, Int64 capacity, MemoryMappedFileAccess access, MemoryMappedFileOptions options, MemoryMappedFileSecurity memoryMappedFileSecurity, HandleInheritability inheritability)
根据任务经理的说法,我仍然可以获得很多Ram,当它发生时,我的过程大约是3G,装有15G Ram的盒子。
我的进程在多个线程上每分钟创建并销毁数百个这些内存映射文件。
我遇到了某种我不知道的限制吗?
我抛出异常的类似乎正确处理了内存,它始终在using语句中
internal unsafe class VirtuallyBackedMemory : IDisposable
{
private readonly MemoryMappedViewAccessor _accessor;
private readonly MemoryMappedFile _file;
public VirtuallyBackedMemory(string name, long sizeInBytes)
{
_file = MemoryMappedFile.CreateNew(name,sizeInBytes, MemoryMappedFileAccess.ReadWrite);
_accessor = _file.CreateViewAccessor(0, sizeInBytes, MemoryMappedFileAccess.ReadWrite);
BaseAddress = _accessor.Pointer(0);
}
public byte* BaseAddress { get; }
~VirtuallyBackedMemory()
{
Dispose(false);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
if (_accessor != null)
{
if (BaseAddress != null)
_accessor.SafeMemoryMappedViewHandle.ReleasePointer();
_accessor.Dispose();
}
if (_file != null)
_file.Dispose();
}
}
}