Delete CryptoContext object

Hi everyone!
I’m developing an application that uses several different CryptoContexts, e.g. in separate function calls. I would like to delete them during the application while it is still running, because they occupy a lot of memory. I found out, that CryptoContext is an alias for std::shared_ptr<CryptoContextImpl> and this shared_ptr is saved for example in a static object in CryptoContextFactory. I managed to delete it from here by using CryptoContextFactory::ReleaseAllContexts, but std::shared_ptr::use_count still shows some number of CryptoContext owners. Could it be other static objects? Is it possible to remove all occurrences of the given CryptoContext at once?

Thank you in advance!

@Arseniy You are right. Any generated key includes a pointer to the cryptocontext used to generate it. In order to release all cryptocontexts, you should call all clearing key functions: ClearEvalAutomorphismKeys() and/or ClearEvalMultKeys()