import resource


def limit_memory(memory):
    """
    Set the maximum usable limit for a process
    :param memory: Maximum memory amount
    :return: setrlimit lambda expression result
    """
    return lambda: resource.setrlimit(resource.RLIMIT_AS, (memory, memory))