paulirwin commented on issue #1090: URL: https://github.com/apache/lucenenet/issues/1090#issuecomment-2574368190
@NightOwl888 Actually, once I started digging into this, I'm no longer sure about that. I think the exception is coming from here: ```c# if (input.memoryMappedFile is null) { input.memoryMappedFile = MemoryMappedFile.CreateFromFile( fileStream: fc, mapName: null, capacity: length, access: MemoryMappedFileAccess.Read, #if FEATURE_MEMORYMAPPEDFILESECURITY memoryMappedFileSecurity: null, #endif inheritability: HandleInheritability.Inheritable, leaveOpen: true); // LUCENENET: We explicitly dispose the FileStream separately. } ``` This is the place where `MemoryMappedFile.CreateCore` could be inlined, and it also does the `capacity` parameter check. (The later call with the "adjust" math ultimately calls CreateViewAccessor which does not have a capacity. I do think we can still do what you suggest, though.) I can't currently explain the failure, because the capacity is just set to the FileStream length, and that is also what that method checks for internally, so they should be equal - that is, unless the FileStream changed length somehow between the MMapIndexInput ctor and the call to CreateFromFile... if that is true, we could pass `fc.Length` instead of `length` as the capacity to help cut down on the likelihood of that changing, but probably wouldn't eliminate it. Let me know if I'm missing something on this or if you have any other ideas. Where it throws the exception in `MemoryMappedFile.VerifyMemoryMappedFileAccess`: ```c# if (fileSize > capacity) { throw new ArgumentOutOfRangeException(nameof(capacity), SR.ArgumentOutOfRange_CapacityGEFileSizeRequired); } ``` https://source.dot.net/#System.IO.MemoryMappedFiles/System/IO/MemoryMappedFiles/MemoryMappedFile.Unix.cs,26 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@lucenenet.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org