def set_mem_rlimit(max_mem=None):
 import resource
 if (max_mem is None):
  mem_info = get_mem_info()
  max_mem = int((mem_info['memtotal'] * 0.7))
 cur_limit = resource.getrlimit(resource.RLIMIT_AS)
 if (cur_limit[0] > 0):
  max_mem = min(max_mem, cur_limit[0])
 resource.setrlimit(resource.RLIMIT_AS, (max_mem, cur_limit[1]))

def set_mem_rlimit ( max_mem = None ) : import resource if ( max_mem is None ) : mem_info = get_mem_info ( ) max_mem = int ( ( mem_info [ 'memtotal' ] * 0.7 ) ) cur_limit = resource . getrlimit ( resource . RLIMIT_AS ) if ( cur_limit [ 0 ] > 0 ) : max_mem = min ( max_mem , cur_limit [ 0 ] ) resource . setrlimit ( resource . RLIMIT_AS , ( max_mem , cur_limit [ 1 ] ) )
set address space rlimit .