import mmap import contextlib import sys print sys.version with open('C:\\bigfile.log', 'r+') as f: with contextlib.closing(mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)) as m: print m.readline().rstrip() 

When using mmap, a WindowsError: [Error 8] error occurs, which indicates a lack of memory. Why does this error occur and how can it be fixed?

PS File size ~ 2 GB

1 answer 1

Use the 64 bit version of python. The fact is that 32-bit applications have limited memory size.

I somehow opened the json file size of 1 gig and there was the same problem.

  • There are several factors: the limitation of 32-bit address space (which differs from the available memory), plus how the concrete implementation of Python works (see the bug at the top). - jfs