Commit Graph

7 Commits

Author SHA1 Message Date
Ethan Atkins 03bf539ce9 Add new ClassLoaderCache implementation
This commit adds a new ClassLoaderCache that builds on the
ClassLoaderCache that is present in zinc (and can be used to build an
instance of the zinc ClassLoaderCache to preserve compatibility). It
differs from the zinc classloader cache that it does not use direct
SoftReferences to classloaders. Instead, we create a wrapper loader
that can't load any classes and just delegates to its parent. This
allows us to add a thread that reaps the soft reference to the wrapper
loader. Crucially, we add a custom SoftReference class that has a strong
reference to the underlying classloader. This allows us to call close on
the strong reference.

The one issue with this approach is that we can't
rescue the jvm from crashing with an OOM: metaspace because the jvm
doesn't give us a chance to close and dereference the underlying
classloaders before it crashes. It WILL collect classloaders under
normal memory pressure, just not metaspace pressure. To fix this, I
check if the MaxMetaspaceSize is set via an MxBean and, if it is, we
fill the cache with regular soft references. We are going to change the
bash script to not set -XX:MaxMetaspaceSize by default so most builds
should probably end up correctly closing the classloaders after this
change. But we should break existing builds that set MaxMetaspaceSize
but don't crash.

As part of this commit, I audited all of the places where we were
instantiating ClassLoaderCache instances and instead pass in the
state's ClassLoaderCache instance. This reduces the total number of
classloaders created.
2019-05-28 09:53:35 -07:00
Ethan Atkins f4a2bcd0ce Close URLClassLoaders after getting bridge
The ZincComponentCompilerSpec was fail with a metaspace related error
when run locally with a recent version of sbt on my machine. I was able
to stop these failures by closing the URLClassLoader instances used to
compile the bridge.
2019-04-30 12:24:47 -07:00
Dale Wijnand d51a5ef16e
Miscellaneous zinc-lm-integration cleanups 2019-04-29 14:40:55 +01:00
Dale Wijnand 736a1fa624
Switch back to unsuffixed 2.13 compiler bridge sources
Using the newer zinc version there now is a compiler bridge source jar
with suffix _2.13.
2019-04-28 23:41:48 +01:00
Eugene Yokota 04197db2ec formatting 2019-04-28 17:27:24 -04:00
Dale Wijnand 9a56c0d005
Cleanup zinc-lm-integration 2019-04-25 12:01:33 +01:00
Dale Wijnand e978357e47
In-source zinc's LM integration code 2019-04-25 11:57:37 +01:00