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

[jssrc2cpg] Pass JVM max memory setting to astgen #4990

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,17 @@ object AstGenRunner {

private val LineLengthThreshold: Int = 10000

private val NODE_OPTIONS: Map[String, String] = Map("NODE_OPTIONS" -> "--max-old-space-size=8192")
private def getMaxHeapSizeInMB: Long = {
val maxHeapSizeInBytes = Runtime.getRuntime.maxMemory()
val maxHeapSizeInMB = maxHeapSizeInBytes / (1024 * 1024)
maxHeapSizeInMB // nodejs expects MB
}

private def nodejsSpaceSize: Int = {
Math.max((0.75 * getMaxHeapSizeInMB).toInt, 8192) // as default we set 8G minimum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that this isn't really a change, but I'm still wondering if setting a (rather high) minimum is the right idea, given that it may exceed the free memory, and/or even the physically available memory.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would assume this memory will be long freed when it needs to be reclaimed by java again. This is done under the assumption the end user will set up java mem thinking that this is all it takes for the cpg process

}

private val NODE_OPTIONS: Map[String, String] = Map("NODE_OPTIONS" -> s"--max-old-space-size=$nodejsSpaceSize")

private val TypeDefinitionFileExtensions = List(".t.ts", ".d.ts")

Expand Down
Loading