Runtime: Creating MemoryMappedFile fails with PlatformNotSupportedException

Created on 22 May 2017  路  3Comments  路  Source: dotnet/runtime

Creating a MemoryMapped (in memory segment) failed on RHEL .NET Core App 1.1

ctor used:

mmf = MemoryMappedFile.CreateNew(_FeedName, _StreamCapacity, MemoryMappedFileAccess.ReadWrite);
mvs = mmf.CreateViewStream();
mvs.Seek(0, SeekOrigin.Begin);

stack trace

1 22-05-2017 08:24:38.626675 [1] Starting program at 08:24:38.6204093Utc
2 22-05-2017 08:24:38.650215 [7] Creating MemoryMap publiser FXTest
System.PlatformNotSupportedException: Named maps are not supported.
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateCore(FileStream fileStream, String mapName, HandleIn heritability inheritability, MemoryMappedFileAccess access, MemoryMappedFileOptions options, Int64 capacity)
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateNew(String mapName, Int64 capacity, MemoryMappedFile Access access, MemoryMappedFileOptions options, HandleInheritability inheritability)
at ConsoleApp1.FairValueMemoryMapPublisher.CreateMemoryMappedFile()
3 22-05-2017 08:24:38.775615 [7] Starting Publication
4 22-05-2017 08:24:38.777373 [7] Starting Publication
5 22-05-2017 08:24:38.780634 [7] System.NullReferenceException: Object reference not set to an instance of a n object.
at ConsoleApp1.FairValueMemoryMapPublisher.PublishOnMemoryMap(ABCD entity)
at ConsoleApp1.Program.StartMemMapPublisher(String _FeedName)

area-System.IO bug os-linux

Most helpful comment

Names are a feature provided by Windows. In general, memory-mapped _files_ work by cross-process communication by mapping the same file into multiple processes, e.g. using MemoryMappedFile.CreateFromFile. You can see an example in the test here: https://github.com/dotnet/corefx/blob/master/src/System.IO.MemoryMappedFiles/tests/MemoryMappedFile.CrossProcess.cs#L13

All 3 comments

@samirparekh, _named_ memory mapped files are not supported on Unix. You can create anonymous maps, just by passing null as the name. You can also create maps for actual files, e.g. with CreateFromFile.

a silly question but, in case of a null being passes in name, how does the client access the same memory mapped file, is there some sort of ID or something to identify the corresponding memory map?

Names are a feature provided by Windows. In general, memory-mapped _files_ work by cross-process communication by mapping the same file into multiple processes, e.g. using MemoryMappedFile.CreateFromFile. You can see an example in the test here: https://github.com/dotnet/corefx/blob/master/src/System.IO.MemoryMappedFiles/tests/MemoryMappedFile.CrossProcess.cs#L13

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jkotas picture jkotas  路  3Comments

EgorBo picture EgorBo  路  3Comments

matty-hall picture matty-hall  路  3Comments

Timovzl picture Timovzl  路  3Comments

chunseoklee picture chunseoklee  路  3Comments