# Closing attributes, etc.

**URL:** <https://forum.hdfgroup.org/t/closing-attributes-etc/9184>\
**Category:** h5py\
**Created:** [November 23, 2021, 8:54pm UTC](https://forum.hdfgroup.org/t/closing-attributes-etc/9184 "2021-11-23T20:54:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zac.chance](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/z/3da27b/32.png) [@zac.chance](https://forum.hdfgroup.org/u/zac.chance)\
**Post date:** [November 23, 2021, 8:54pm UTC](https://forum.hdfgroup.org/t/closing-attributes-etc/9184/1 "2021-11-23T20:54:51Z")

</div>

Hi!

I was curious if there were plans to add the ability to close an attribute/type/space. Maybe via a “close” method or upon object delete? For instance, H5Aclose, H5Sclose, H5Tclose are currently only used in the .pyx source code but are not available in the low-level API. For files with large amounts of objects with attributes, keeping all attributes/spaces/types open may accumulate a memory footprint over time.

Thanks,  
Zac

---

<div class="post-metadata">

**Author:** ![thomas1](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/thomas1/32/1733_2.png) [@thomas1](https://forum.hdfgroup.org/u/thomas1)\
**Post date:** [May 24, 2022, 10:58am UTC](https://forum.hdfgroup.org/t/closing-attributes-etc/9184/2 "2022-05-24T10:58:55Z")

</div>

Hi Zac,

h5py aims to bridge Python & HDF5’s reference counting, so when a Python object goes out of scope (e.g. local variables in a function that’s finished), its HDF5 ID is also cleaned up. You shouldn’t normally need to do any explicit cleanup of these objects.

If you do need it for some reason, objects in [h5py’s low-level API](https://api.h5py.org/), like AttrID, SpaceID, etc. all have a `.close()` method. This actually calls `H5Idec_ref` rather than one of the `H5*close` C functions, but that should do the same thing.
