Message128305
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)
f.flush()
fm = mmap.mmap(f.fileno(), 0)
fm.close()
f.truncate(5 * 1024 ** 3)
# mmap only 1GiB of the 5GiB file
fm = mmap.mmap(f.fileno(), 1024**3)
fm.close()
f.close() |
|
Date |
User |
Action |
Args |
2011-02-10 16:41:47 | rosslagerwall | set | recipients:
+ rosslagerwall, loewis, pitrou, vstinner, wrobell, nadeem.vawda, eckhardt, saa, jbeezley |
2011-02-10 16:41:47 | rosslagerwall | set | messageid: <1297356107.57.0.130274937134.issue4681@psf.upfronthosting.co.za> |
2011-02-10 16:41:45 | rosslagerwall | link | issue4681 messages |
2011-02-10 16:41:45 | rosslagerwall | create | |
|