[Python-Dev] Memory tests in Unicode (original) (raw)

Victor Stinner victor.stinner at haypocalc.com
Sat Aug 16 17:33:10 CEST 2008


Hi,

Le Saturday 16 August 2008 15:43:28 Facundo Batista, vous avez écrit :

The testraiseMemError() in testunicode.py is complicating me the regression tests: tries to use all the memory in my system, which starts to swap as crazy, and almost freezes everything.

On UNIX, it's possible to limit a process memory using RLIMIT_AS:

from resource import getrlimit, setrlimit, RLIMIT_AS

def limitMemory(soft):
    try:
        old_soft, hard = getrlimit(RLIMIT_AS)
        if old_soft != -1:
            soft = min(soft, old_soft)
    except ValueError:
        hard = -1
    setrlimit(RLIMIT_AS, (soft, hard))

Values are in bytes. So it's possible to get MemoryError without using the whole system memory.

Victor



More information about the Python-Dev mailing list