Skip to content

Instantly share code, notes, and snippets.

@blazetopher
Created May 16, 2013 16:51
Show Gist options
  • Save blazetopher/5593215 to your computer and use it in GitHub Desktop.
Save blazetopher/5593215 to your computer and use it in GitHub Desktop.
hunting down the memory lost when loading coverages
import gevent
import gc
from load_datasets import *
def get_mem():
import resource
return resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / (1024.0**2)
data_product_id, stream_id, route, stream_def_id, dataset_id = create_data_product('ctd_parsed_param_dict')
populate_data_product(data_product_id,1)
for x in xrange(10):
s = get_mem()
cov = pn.dataset_management._get_coverage(dataset_id)
e = get_mem()
print e-s, 'mb'
cov.close()
gevent.sleep(0.2)
print ''
from coverage_model import AbstractCoverage
root = '/tmp/ion/run/cache/datasets/'
for x in xrange(10):
s = get_mem()
cov = AbstractCoverage.load(root, dataset_id, mode='r')
e = get_mem()
print e-s, 'mb'
cov.close()
gevent.sleep(0.2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment