Skip to content

Memory leak in LazyList + Java 25 combination #25777

@charpov

Description

@charpov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:jdkIssues tied to artifacts published under a particular jdkitype:bugstat:needs investigationHard to to tell much without investigating this further. Needs a spike.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions