Resource controls¶
Normal plotting needs no configuration. Curve generation memoises stroke data; coordinate and derived image arrays may still be allocated again on later calls.
An order-k path contains 4**k cells. Coordinates alone cost 16 bytes per cell; images, masks, FFTs and intermediate arrays add to peak memory. The default cell limit is a guard against accidental huge allocations, not a reserved memory budget.
import hilbertplot as hp
previous = hp.config.set_cell_limit(4**10)
try:
# work within the temporary limit
pass
finally:
hp.config.set_cell_limit(previous)
hp.config.clear_cache()
- hilbertplot.config.cache_info()¶
Return statistics for cached recursive curve construction.
- Returns:
info – Standard functools cache statistics: hits, misses, maxsize, currsize. maxsize is None for this unbounded memo cache. currsize counts recursive construction entries, not cells or bytes.
- Return type:
namedtuple
See also
hilbertplot.config.clear_cacheRelease cached construction entries.
Notes
The cache stores recursive stroke arrays shared between curves. It does not report arrays owned by callers or open Matplotlib figures.
Examples
>>> import hilbertplot as hp >>> hp.config.cache_info().maxsize is None True
- hilbertplot.config.clear_cache()¶
Clear memoized recursive stroke arrays and reset cache statistics.
- Returns:
The generation cache is cleared in place.
- Return type:
None
See also
hilbertplot.config.cache_infoInspect cache entries and hit/miss counts.
Notes
Does not close figures or release arrays referenced elsewhere. A process’s resident memory need not decrease immediately, because Python and NumPy allocators may retain freed memory for reuse.
Examples
>>> import hilbertplot as hp >>> hp.config.clear_cache() >>> hp.config.cache_info().currsize 0
- hilbertplot.config.cell_limit()¶
Return the process-wide ceiling for a materialized curve request.
- Returns:
cells – Maximum permitted number of cells in one request. The default is 2**28; this is a ceiling, not preallocated or reserved memory.
- Return type:
int
See also
hilbertplot.config.set_cell_limitChange or restore the guard.
Notes
Coordinate pairs alone cost 16 bytes per cell. Temporary arrays, cached strokes, images and rendering can substantially increase peak memory. Direct index_to_xy/xy_to_index calls do not materialize a grid.
- hilbertplot.config.set_cell_limit(cells)¶
Set the ceiling on a single materialised curve and return the previous value.
- Parameters:
cells (int or None) – The new limit in cells.
Nonerestores the default; a limit of0or less is rejected. Pass a very large number to effectively disable the check.- Returns:
The limit that was in force before this call, so it can be restored.
- Return type:
int
Examples
>>> import hilbertplot >>> previous = hilbertplot.config.set_cell_limit(4 ** 10) >>> hilbertplot.config.cell_limit() 1048576 >>> _ = hilbertplot.config.set_cell_limit(previous)