MCPcopy Create free account
hub / github.com/NSLS2/PyXRF / free_memory_from_handler

Function free_memory_from_handler

pyxrf/model/load_data_from_db.py:4088–4104  ·  view source on GitHub ↗

Quick way to set 3D dataset at handler to None to release memory.

()

Source from the content-addressed store, hash-verified

4086
4087# TODO: the following function may be deleted after Databroker 0.13 is forgotten
4088def free_memory_from_handler():
4089 """
4090 Quick way to set 3D dataset at handler to None to release memory.
4091 """
4092 # The following check is redundant: Data Broker prior to version 1.0.0 always has '_handler_cache'.
4093 # In later versions of databroker the attribute may still be present if 'databroker.v0' is used.
4094 if (
4095 (LooseVersion(databroker.__version__) < LooseVersion("1.0.0"))
4096 or hasattr(db, "fs")
4097 and hasattr(db.fs, "_handler_cache")
4098 ):
4099 for h in db.fs._handler_cache.values():
4100 setattr(h, "_dataset", None)
4101 print("Memory is released (Databroker v0).")
4102 elif hasattr(db, "_catalog") and hasattr(db._catalog, "_entries"):
4103 db._catalog._entries.cache_clear()
4104 print("Memory is released (Databroker v1).")
4105
4106
4107def export1d(runid, name=None):

Callers 1

fetch_data_from_dbFunction · 0.85

Calls 1

valuesMethod · 0.80

Tested by

no test coverage detected