Skip to content

Add global cache manager to facilitate cleaning memory #693

Closed
@connorjward

Description

@connorjward

In lots of different places in PyOP2 and Firedrake we have global caches implemented something like:

class MyObject:
    _cache = {}

For long running simulations (e.g. CI) this results in a slow leaking of memory as this global cache gets larger and larger. Thetis for example needs to purge the cache at every test to avoid running out of memory.

It would be nice to have some sort of global pyop2.caching.cache_manager object to hide this. This would mean class-level caches would be implemented something like:

class MyObject:
    _cache = cache_manager.register("MyObject")

then later on in the simulation all (or some) of these caches can be cleaned using cache_manager.clear().

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions