public static void clearOutPmfClassLoaderCache() {
    pmfWriteLock.lock();
    try {
      clearOutPmfClassLoaderCache(pmf);
      clearOutPmfClassLoaderCache(compactorPmf);
    } finally {
      pmfWriteLock.unlock();
    }
  }
Removed cached classloaders from DataNucleus
DataNucleus caches classloaders in NucleusContext.
In UDFs, this can result in classloaders not getting GCed resulting in PermGen leaks.
This is particularly an issue when using embedded metastore with HiveServer2,
since the current classloader gets modified with each new add jar,
becoming the classloader for downstream classes, which DataNucleus ends up using.
The NucleusContext cache gets freed up only on calling a close on it.
We're not closing NucleusContext since it does a bunch of other things which we don't want.
We're not clearing the cache HashMap by calling HashMap#clear to avoid concurrency issues.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/PersistenceManagerProvider.java