Created
February 26, 2016 16:42
-
-
Save lbolla/8e2640133032b0a6bb9c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gc | |
import os | |
import resource | |
def print_mem(): | |
u = resource.getrusage(resource.RUSAGE_SELF) | |
print 'N={} RSS={}'.format(N, u.ru_maxrss) | |
def alloc(N): | |
_x = {i: i for i in xrange(N)} | |
# print_mem() | |
print 'MALLOC_MMAP_THRESHOLD_={} MALLOC_MMAP_MAX_={}'.format( | |
os.environ.get('MALLOC_MMAP_THRESHOLD_'), | |
os.environ.get('MALLOC_MMAP_MAX_'), | |
) | |
for N in xrange(10): | |
alloc(N * 100000) | |
print_mem() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
python alloc.py | |
MALLOC_MMAP_THRESHOLD_=512 python alloc.py | |
MALLOC_MMAP_THRESHOLD_=1024 python alloc.py | |
MALLOC_MMAP_THRESHOLD_=2048 python alloc.py | |
MALLOC_MMAP_THRESHOLD_=4096 python alloc.py | |
MALLOC_MMAP_THRESHOLD_=100000 python alloc.py | |
MALLOC_MMAP_THRESHOLD_=512 MALLOC_MMAP_MAX_=0 python alloc.py | |
MALLOC_MMAP_THRESHOLD_=1024 MALLOC_MMAP_MAX_=0 python alloc.py | |
MALLOC_MMAP_THRESHOLD_=2048 MALLOC_MMAP_MAX_=0 python alloc.py | |
MALLOC_MMAP_THRESHOLD_=4096 MALLOC_MMAP_MAX_=0 python alloc.py | |
MALLOC_MMAP_THRESHOLD_=100000 MALLOC_MMAP_MAX_=0 python alloc.py | |
MALLOC_MMAP_THRESHOLD_=512 MALLOC_MMAP_MAX_=16777216 python alloc.py | |
MALLOC_MMAP_THRESHOLD_=1024 MALLOC_MMAP_MAX_=16777216 python alloc.py | |
MALLOC_MMAP_THRESHOLD_=2048 MALLOC_MMAP_MAX_=16777216 python alloc.py | |
MALLOC_MMAP_THRESHOLD_=4096 MALLOC_MMAP_MAX_=16777216 python alloc.py | |
MALLOC_MMAP_THRESHOLD_=100000 MALLOC_MMAP_MAX_=16777216 python alloc.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment