soft, hard = resource.getrlimit(rsrc)
print('Soft limit starts as  :', soft)
resource.setrlimit(rsrc, (1024, hard))
soft, hard = resource.getrlimit(rsrc)
print('Soft limit changed to :', soft)
How to limit the heap size?