views:

34

answers:

1

I made a memory mapped file using MemoryMappedFile.CreateNew(mapName, capacity) of .net 4

Can i access this mmf by the mapName from cpython ?

I tried like below.

import mmap
map = mmap.mmap(-1, 0, mapName, 1)

but it returns WindowsError [error 87] saying the parameter is incorrect.

I'm using windows vista.

A: 

I have absolutely no experience with C#, but I'll attempt to answer your question.

CreateNew should create a mapping to a file that doesn't reside in the filesystem. Note that this isn't cross platform in any way. On Windows, the tagname parameter of mmap.mmap should allow you to map these tagged mappings. Since the mapping is not backed by a file, the -1 for fileno is correct also. The length of 0 will obtain the entire mapping. The issue then lies with access. There is a mention that not providing the access parameter will give write-through mapping on Windows, you might try experimenting with this.

If all else fails, try falling back to using a file-backed memory mapping, it's more portable, and far more common. The C# MemoryMappedFile class provides the CreateFromFile method for this.

Matt Joiner
Thnx Matt.. It still fails with different accessing options, but i got that this 'non file-backed' is windows only function.
tk
I mean, try not providing the access parameter at all. That seems to be what the doco suggests.
Matt Joiner