Closed jzrake closed 3 years ago
Could be a duplicate of #76
Yea on the top of it, it seems like the same thing, probably should be worth looking into again...
I tested the program with our Registry
removed. Running this did not give an increase in memory used. Running valgrind
show the only leak is from the lazy_statics
.
As discussed in #76, if you simply remove Registry
, you'll definitely cause troubles on HDF5 1.8.* since they changed reference counting behaviour in 1.10 (IDs were reused often which would cause frequent clashes, now they are reused less frequently so you have to try hard to make it clash but it's still possible).
It's still a bit weird that over 100k iterations it grows to 2GB. E.g., new group handles should go out of scope and get dropped and dec-refed back to zero? Any plists that are created and accessed in the process should be dropped and decrefed as well? Maybe it's worth printing out contents of registry after these iterations to see how many IDs does it hold and what do those IDs represent? (Maybe they are all plists and we're missing a decref somewhere) I think this would be a more useful approach than simply dropping Registry.
It works out to about 200 bytes per iteration (100 * 100k iterations), with two property lists created every iteration. The registry is quite wasteful, it uses 8 (hid_t) + 8 (Arc) + 8 (Rwlock) + 8 (hid_t) bytes for every entry. The RwLock
can be removed using the global mutex.
Printing the registry results in a bunch of -1
s. Do you intend for invalid entries to be removed from the registry?
I wonder, as soon as we invalidate a certain hid (set it to -1 across all objects sharing it and update the value in the hashmap), can we just simply remove it from the hashmap, what will that cause? (The Arc<RwLock>>
will still exist shared across those objects, it's just the key will no longer be present in the hashmap)
The following is a reproducer for what seems like a fatal memory leak.
Rust crate version: 0.7.1 HDF5 Version: 1.12.0 OS: MacOS, Linux
Memory usage grows linearly from 10MB to 2GB over 100,000 iterations
Memory usage is stable at 15MB