def getMemoryLimit(): try: limit = getrlimit(RLIMIT_AS)[0] if 0 < limit: limit *= PAGE_SIZE return limit except ValueError: return None