Last active
December 11, 2015 02:38
-
-
Save blazetopher/4531499 to your computer and use it in GitHub Desktop.
Demonstrates memory leak when writing attributes using h5py & HDF
This file contains hidden or 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
if __name__ == '__main__': | |
import time | |
import h5py | |
import os | |
rng = range(1000) | |
reps = range(3) | |
op = 'test.h5py' | |
if os.path.exists(op): os.remove(op) | |
time.sleep(10) | |
with h5py.File(op, 'a') as f: | |
f.attrs['a'] = 'atongowethoing' | |
f.attrs['b'] = 'towinetpiahgnpaiunrg' | |
f.attrs['c'] = 'apointhapgpauerpvuahps9er;soieuhrpauinprbnap9erhfpaoish;iuoaeiruvaperh;aosehr;aoishpunaerpvhaerp98gha;roihta;sobefpa9nvwep9aher;oihta;s9ehra;s98ehrshge98haw9uegubav9rwehg89whg9whg949887t10378rohwoirua98yvyh02h3t89hagw98ryaoisehgoaivpaorjgpao4ut0923y2ut4' | |
time.sleep(20) | |
for r in reps: | |
for x in rng: | |
atts = {} | |
with h5py.File(op, 'a') as f: | |
for key, val in f.attrs.iteritems(): | |
atts[key] = val | |
with h5py.File(op, 'a') as f: | |
for a, v in atts.iteritems(): | |
f.attrs[a] = v | |
time.sleep(0.1) | |
time.sleep(20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment