2

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.

2
  • I think you have severely confused memory mapping. Commented Jul 15, 2010 at 15:38
  • @Matt, I also think i'm confused. But i made a mmf in system memory using the .net function above, and access it from another process (another .net app) efficiently. So, i just guess that it may be possible to access that system memory from python too, bcz the shared data is a plain old data. Commented Jul 15, 2010 at 15:47

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.