Make virtual file value cache global

In 0d2b00c7e9, I introduced a setting for
the virtual file defines class cache to avoid ooms coming from zinc
stamping the project jar files. I introduced that cache at the compile
level though rather than global level and crashes were still occurring
in the sbt build. It was very easy to induce a crash on my computer by
running compile a few times, reload and then compile again. After making
the cache global, the crashes went away.
This commit is contained in:
Ethan Atkins 2020-08-13 17:42:19 -07:00
parent ef34a33ac9
commit adf28877bc
1 changed files with 2 additions and 1 deletions

View File

@ -405,6 +405,8 @@ object Defaults extends BuildCommon {
) )
}, },
fileConverter := MappedFileConverter(rootPaths.value, allowMachinePath.value), fileConverter := MappedFileConverter(rootPaths.value, allowMachinePath.value),
// The virtual file value cache needs to be global or sbt will run out of direct byte buffer memory.
classpathDefinesClassCache := VirtualFileValueCache.definesClassCache(fileConverter.value),
fullServerHandlers := { fullServerHandlers := {
Seq( Seq(
LanguageServerProtocol.handler(fileConverter.value), LanguageServerProtocol.handler(fileConverter.value),
@ -788,7 +790,6 @@ object Defaults extends BuildCommon {
else old else old
}, },
persistJarClasspath :== true, persistJarClasspath :== true,
classpathDefinesClassCache := VirtualFileValueCache.definesClassCache(fileConverter.value),
classpathEntryDefinesClassVF := { classpathEntryDefinesClassVF := {
(if (persistJarClasspath.value) classpathDefinesClassCache.value (if (persistJarClasspath.value) classpathDefinesClassCache.value
else VirtualFileValueCache.definesClassCache(fileConverter.value)).get else VirtualFileValueCache.definesClassCache(fileConverter.value)).get