This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rosslagerwall
Recipients eckhardt, jbeezley, loewis, nadeem.vawda, pitrou, rosslagerwall, saa, vstinner, wrobell
Date 2011-02-10.16:41:45
SpamBayes Score 4.11362e-09
Marked as misclassified No
Message-id <>
32-bit computers can address up to 4GiB of memory and 64-bit computers can address much more than this. mmap() allows a file to be mapped to a location in memory - the actual amount of memory that exists doesn't matter. This is the reason why a 5GiB file can be mmaped on 64-bit but not 32-bit.

Also, python uses the ssize_t type for sequences which allows about 2GiB to be mapped on a 32-bit platform. The mmap.resize() operation as well as changing the size of the underlying file size with ftruncate(), also changes the size of the map in memory. Thus in your sample script, this resizing would need to ftruncate the file to 5GiB and then map all of it into memory which is not possible on 32-bit.

I think the following might be a possible way of doing it:
import mmap

f = open('test.x', 'w+b')
f.write(b'\x00' * 10)

fm = mmap.mmap(f.fileno(), 0)
f.truncate(5 * 1024 ** 3)

# mmap only 1GiB of the 5GiB file
fm = mmap.mmap(f.fileno(), 1024**3)

Date User Action Args
2011-02-10 16:41:47rosslagerwallsetrecipients: + rosslagerwall, loewis, pitrou, vstinner, wrobell, nadeem.vawda, eckhardt, saa, jbeezley
2011-02-10 16:41:47rosslagerwallsetmessageid: <>
2011-02-10 16:41:45rosslagerwalllinkissue4681 messages
2011-02-10 16:41:45rosslagerwallcreate