Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OutOfMemoryError since 4.9.0 #3650

Closed
xuwei-k opened this issue Mar 16, 2024 · 4 comments · Fixed by #3652 or #3656
Closed

OutOfMemoryError since 4.9.0 #3650

xuwei-k opened this issue Mar 16, 2024 · 4 comments · Fixed by #3652 or #3656

Comments

@xuwei-k
Copy link
Contributor

xuwei-k commented Mar 16, 2024

xuwei-k/scalameta-memory-issue-3650@765dccb

reproduce code

package example

import scala.meta._
import scala.meta.inputs.Input
import scala.meta.parsers.Parse
import scala.meta.prettyprinters._
import scala.meta.transversers._
import scala.jdk.StreamConverters._
import java.io.File

object Main {
  def main(args: Array[String]): Unit = {
    // parse many scala code
    // e.g. https://github.com/scala/scala 2.13.x branch
    java.nio.file.Files.find(
      new File("scala", "src").toPath,
      100,
      (p, _) => p.toFile.getName.endsWith(".scala") && (p.toFile.getName != "Singleton.scala")
    ).toScala(List).map { f =>
      val tree = implicitly[Parse[Source]].apply(Input.File(f), scala.meta.dialects.Scala213Source3).get
      tree.traverse { a => () }
      tree
    }
  }
}

VisualVM results in my local Mac

4.8.15

meta-4-8-img-1 meta-4-8-img-2

4.9.0

meta-4-9-img-1 meta-4-9-img-2

GitHub Actions result

4.8.15

[info] running (fork) example.Main 
[success] Total time: 18 s, completed Mar 16, 2024, 4:43:48 AM

4.9.0

[info] running (fork) example.Main 
[error] Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

note

generated too many TrieMap. maybe f840d2e 🤔

@xuwei-k
Copy link
Contributor Author

xuwei-k commented Mar 16, 2024

scalafmt gc log

scalafmt 3.8.0( scalameta 4.9.0)

scalameta-4-9-img-1 scalameta-4-9-img-2

scalafmt 3.7.17( scalameta 4.8.14)

scalameta-4-8-img-1 scalameta-4-8-img-2

@kitbellew
Copy link
Contributor

this seems like a strange oversight to me: f840d2e#diff-328bbe30c12809ccabef99878be748a69632e114e66ba67003f7be8d3b77d1e1R64

not sure if lazy vals can contribute.

@kitbellew
Copy link
Contributor

@xuwei-k is it possible to verify whether this problem is present in 4.9.3, please?

@xuwei-k
Copy link
Contributor Author

xuwei-k commented Apr 2, 2024

I have confirmed not present in 4.9.3. Thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants