This is a memory snapshot of a Scala 3.8.3 program:
Native Memory Tracking:
(Omitting categories weighting less than 1GB)
Total: reserved=55GB, committed=48GB
malloc: 46GB #217214191, peak=42GB #217214192
mmap: reserved=10GB, committed=3GB
- Java Heap (reserved=8GB, committed=2GB)
(mmap: reserved=8GB, committed=2GB, at peak)
- Class (reserved=1GB, committed=0GB)
(classes #4365)
( instance classes #3986, array classes #379)
(mmap: reserved=1GB, committed=0GB, at peak)
( Metadata: )
( reserved=0GB, committed=0GB)
( used=0GB)
( waste=0GB =0.76%)
( Class space:)
( reserved=1GB, committed=0GB)
( used=0GB)
( waste=0GB =4.02%)
- Native Memory Tracking (reserved=4GB, committed=4GB)
(tracking overhead=4GB)
- Synchronization (reserved=2GB, committed=2GB)
(malloc=2GB tag=Synchronization #3344861) (at peak)
- Object Monitors (reserved=40GB, committed=40GB)
(malloc=40GB tag=Object Monitors #213798144) (at peak)
Notice the 40GB (and counting!) of object monitors. My investigation so far has revealed two things:
- This is happening with Java 25, not 21 or 17.
- This stops (with Java 25) if I replace all the
LazyList in the program with List.
Note that the program is small, has nothing to do with threads, and creates 40GB of monitors under a minute.
I've observed the behavior on both Linux and macOS.
I can do more digging, but I want to make sure this is not a known bug before I invest more time.
This is a memory snapshot of a Scala 3.8.3 program:
Notice the 40GB (and counting!) of object monitors. My investigation so far has revealed two things:
LazyListin the program withList.Note that the program is small, has nothing to do with threads, and creates 40GB of monitors under a minute.
I've observed the behavior on both Linux and macOS.
I can do more digging, but I want to make sure this is not a known bug before I invest more time.