Shared Memory Modules

Irmen de Jong irmen at -NOSPAM-REMOVETHIS-xs4all.nl
Tue Nov 25 14:16:28 EST 2003


Thomas Heller wrote:

>>Does the Windows version really support shared memory, or is the 
>>multiple-maps-per-file feature only valid within a single process?
> 
> 
> Yes, it does.  You have to give this memory block a name, though:
> 
> sharedmem = mmap.mmap(0, 16384, "GlobalSharedMemory")
> 
> This allows to access 16384 bytes of memory, shared across processes,
> not backed up by a file in the filesystem.

That is très cool, it doesn't tell you this in the docs, does it?
The first argument is 'the file handle' of the file to be mapped,
and it doesn't say that 0 is valid and means 'no file at all'...

However, I've just tried it, and managed to crash Python in mmap.pyd
with an application exception... twice. But trying to reproduce it
now fails-- Python keeps running.
I did this:
 >>> import mmap
 >>> mem=mmap.mmap(0,3000000,'irmen')
 >>> mem[0]='a'
 >>> mem[2000000]='a'
and initially, it crashed......... Python 2.3.2 on win xp)

--Irmen





More information about the Python-list mailing list