How do you get xodus to completely shut down and release resources?
Closing all environments that are open does not stop the shared threads, nor release (sometimes massive) amounts of data in the cache.
For example, right now, I have a supposedly stopped xodus environment, but I still have jetbrains.exodus.core.dataStructures.ConcurrentLongObjectCache$CacheEntry (and its related byte[] objects) using 8 GB of RAM, which I want reclaimed...
--followup--
The following code is what I found necessary to release the cached memory, mostly held in static objects by xodus:
Field tailPages = Class.forName("jetbrains.exodus.log.SharedLogCache").getSuperclass().getDeclaredField("TAIL_PAGES_CACHE");
tailPages.setAccessible(true);
Object concurrentLongObjectCache = tailPages.get(null); //static field
Method clear = Class.forName("jetbrains.exodus.core.dataStructures.ConcurrentLongObjectCache").getMethod("clear");
clear.invoke(concurrentLongObjectCache);
Log.invalidateSharedCache();
SharedOpenFilesCache.invalidate();
The following call will stop most of the threads:
ThreadJobProcessorPool.getProcessors().forEach(jobProcessor -> jobProcessor.finish());
I've found, I can safely restart xodus after calling any/all of the above.
If you want to stop all of the threads, do this:
Field spawner = ThreadJobProcessorPool.class.getDeclaredField("SPAWNER");
spawner.setAccessible(true);
Object threadJobSpawner = spawner.get(null); //static field
threadJobSpawner.getClass().getMethod("finish").invoke(threadJobSpawner);
However, I've found that xodus does not properly restart after doing that - there is something off with the way the SPAWNER tries to restart itself, which I haven't looked into.