Hi Anthony, A Wednesday 28 January 2009, afog...@princeton.com escrigué: > I have a class that reads data from a number of HDF5 files, and to > save time opening them, I'm trying to use a WeakValueDictionary as a > simple cache. But File objects seem to have more references than > just the label returned from openFile. > > In [1]: import weakref > > In [2]: import tables > > In [3]: cache = weakref.WeakValueDictionary() > > In [4]: fyle = tables.openFile('Foo-1990.h5') > > In [5]: import sys > > In [6]: sys.getrefcount(fyle) > Out[6]: 6 > > In [9]: cache[0] = fyle > > In [10]: sys.getrefcount(fyle) > Out[10]: 6 > > In [11]: del fyle > > In [12]: cache.keys() > Out[12]: [0] > > In [13]: sys.getrefcount(cache.values()[0]) > Out[13]: 5 > > (In this example 'Foo-1990.h5' has roughly 250 Arrays, all off the > root group, but I've opened up files with only three arrays and > gotten even higher refcounts.) > > I've checked to see whether PyTables is caching the file instances, > but repeated calls to tables.openFile return different objects. > > What is holding these references? What is the proper way to > completely remove a File object?
At least each open node keeps a reference to the File object. So, in order to remove the File object you must close the nodes that reference to them. See the File.close() for an example on how to do this. I don't know if I have addressed your issue, but if not, please tell me. HTH, -- Francesc Alted ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ Pytables-users mailing list Pytables-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pytables-users