Large memory consumption when using Mooncake via DifferentiationInterface for Gaussian process optimisation

Ah, yes, so this is Mooncake’s caching mechanism doing it’s thing. There’s a bunch of memory that it holds on to in a global variable so that it doesn’t have to reallocate it each time that you differentiate a function that you’ve seen before.

If you call

empty!(Mooncake.get_interpreter().oc_cache) # uses internals -- not part of the public interface (yet)
GC.gc(true)

you should see the memory consumption go back to the usual levels.

I should probably make clearing this cache part of the public interface…