Scala staging not releasing memory
See original GitHub issueCompiler version
3.0.0
Minimized example
while true do
run(iGenAnExpr)
Output
Lots of stuff in the JVM’s old gen heap
Expectation
Thrown away compiled code is freed.
I believe the issue is in the QuotesDriver. In the above code, I generate a lot of code via runtime MSP, and then never use it. I had thought this would result in memory being freed, but apparently there’s some long-lived storage in the compiler that I haven’t found yet, because the above example causes old gen to rapidly fill.
Issue Analytics
- State:
- Created 2 years ago
- Comments:18 (12 by maintainers)
Top Results From Across the Web
Releasing Scala Object resources - Stack Overflow
Problem is if anyone puts objects into the sandbox code even though all the classes are easily cleaned up, the objects, and any...
Read more >Spark SQL Job stcuk indefinitely at last task of a stage
It executes 72 stages successfully but hangs at 499th task of 73rd stage, and not able to execute the final stage no 74....
Read more >Spark Out of Memory - Criteo Engineering
Our best hypothesis is that we have a memory leak. So we decided to plot the memory consumption of our executors and check...
Read more >JVM memory management. How to find and prevent ... - Scalac
It's harder to cause a memory leak in JVM than e.g in C, but possible. Let's take a look at useful JVM memory...
Read more >Troubleshoot Dataflow errors - Google Cloud
To resolve this issue, have your destination, source, and staging ... occurs if the pipeline is using Java Native Interface (JNI) to run...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
More precisely it comes from the baseTypeCache of some denotations: https://github.com/lampepfl/dotty/issues/12543#issuecomment-849607084 which could be turned into a WeahHashMap (and also maybe shouldn’t cache termrefs at all?)
Not sure if we should change anything in the caching mechanism for staging. It provides the flexibility to either cache and run fast, or not cache and run a bit slower without consuming to much memory.
The optimizations we should be looking at are in the Context itself which are things that also affect the normal compiler. I saw may trees retained which are probably trees attached to symbols, these could in theory be dropped and recomputed.