Our setup involves using a lot of small cores (possibly hundred thousand), but working only on a few of them at any given time.
We already followed all recommendations in this guide: https://wiki.apache.org/solr/LotsOfCores
We noticed that after creating/loading around 1000-2000 empty cores, with no documents inside, the heap consumption went through the roof despite having set transientCacheSize to only 64 (heap size set to 12G).
All cores are correctly set to loadOnStartup=false and transient=true, and we have verified via logs that the cores in excess are actually being closed.
However, a reference remains in the org.apache.solr.metrics.SolrMetricManager#registries that is never removed until a core if fully unloaded.
Restarting the JVM loads all cores in the admin UI, but doesn't populate the ConcurrentHashMap until a core is actually fully loaded.
I reproduced the issue on a smaller scale (transientCacheSize = 5, heap size = 512m) and made a report (attached) using eclipse MAT.
When a transient core is closed, the references in the SolrMetricManager should be removed, in the same fashion the reporters for the core are also closed and removed.
In alternative, a unloadOnClose=true|false flag could be implemented to fully unload a transient core when closed due to the cache size.
The documentation mentions everywhere that the unused cores will be unloaded, but it's misleading as the cores are never fully unloaded.