Shared Memory Modules

Bengt Richter bokr at
Tue Dec 2 02:06:07 CET 2003

On Tue, 02 Dec 2003 00:44:15 +0100, Irmen de Jong <irmen at> wrote:

>Scott David Daniels wrote:
>> Irmen de Jong wrote:
>>> 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
>> Probably not enough actual memory hanging around.  Some systems
>> (and from this I'd guess XP) allocate virtual memory by reserving
>> address space, not actually allocating the RAM and/or backing
>> store for that memory. 
>Over-commit is that called, right?
>I'm sorry but that certainly wasn't the case here.
>My machine has 512 Mb RAM and about 250 Mb of them
>allocated when I tried it. (physical RAM that is)
>Very weird, I cannot reproduce the initial crash I experienced.
What's that first zero argument?

Snip from mmap docs:
mmap( fileno, length[, tagname[, access]]) 

(Windows version) Maps length bytes from the file specified by
the file handle fileno, and returns a mmap object. If length is 0,
the maximum length of the map will be the current size of the file
when mmap() is called.

tagname, if specified and not None, is a string giving a tag name
for the mapping. Windows allows you to have many different mappings
against the same file. If you specify the name of an existing tag,
that tag is opened, otherwise a new tag of this name is created.
If this parameter is omitted or None, the mapping is created without a name.
Avoiding the use of the tag parameter will assist in keeping your code portable
between Unix and Windows.

Does that mean you are trying to use stdin as the open file handle?

Bengt Richter

More information about the Python-list mailing list