scala-dev
scala-dev copied to clipboard
reduce the optimizer's heap requirements
When enabling the sbt build for running the tests on jenkins, we found that the JVM instance to run partest (and thus the compiler instances) needs more memory than on 2.11.x if the optimizer is enabled. concretely, we get OOMEs when running the presentation
if the VM has 1G of memory, it works with 2G. See discussion on https://github.com/scala/scala/pull/5237.
The stack traces show that the optimizer is running out of memory when loading bytecode (for the inliner). There is already code in place to make sure we don't keep too much classes in the BytecodeRepository (https://github.com/scala/scala/commit/57c07204ca452564b930085cfa9e8b099e45b2a9). Probably we can improve on that, for example by lazily loading only those methods that are actually needed. Currently we classes are parsed eagerly and completely.
See also https://github.com/scala/scala-dev/issues/23, an issue where the inliner itself is allocating a lot of memory (unrelated to classfile parsing).