"Out of memory in the CDS archive" error with lot of classes

XMLWordPrintable

    • 25

      JDK: JDK25
      Reproducible: Always
      Test case: attached


      We run an application which generates too many classes. JDK25's AOT is very promising for us but we are hitting the error :

      ```
      [error][aot] [rw] capacity = 1073737728, allocated = 1073737656
      [error][aot] required = 88
      [error][aot] Unable to allocate from 'rw' region: Please reduce the number of shared classes.
      [error][aot] An error has occurred while writing the shared archive file.
      ```


      What happened (we believe):
      - RW region has a 1GB default limit
      - With 307,000 classes, RW allocation hits the limit
      - AOT fails before even starting RO object allocation

      We tried with CompressedClassSpaceSize options too:

      ### With CompressedClassSpaceSize=3.2GB (OOM Moves to RO Phase)

      Using `-XX:CompressedClassSpaceSize=3439329280`:

      ```
      [102.993s][info][aot] Allocating RW objects ...
      [108.649s][info][aot] done (9595235 objects) ✓ RW COMPLETED!
      [108.649s][info][aot] Allocating RO objects ...
      [120.896s][error][aot] Out of memory in the CDS archive
      ```

      **What happened:**
      - RW allocation completes successfully with 9.6M objects
      - OOM occurs during RO allocation phase
      - This matches the real-world application pattern


      We request to increase the AOT limit to higher values. All our investigation is added in README.md too.

        1. aot-oom-proposal.md
          2 kB
        2. ClassGenerator.java
          5 kB
        3. CombinedClassLoader.java
          6 kB
        4. compile-combined-classes.sh
          4 kB
        5. MegaClassGenerator.java
          6 kB
        6. README.md
          8 kB
        7. run-combined-classes-aot.sh
          4 kB

            Assignee:
            Xuelei Fan
            Reporter:
            Vaibhav Choudhary
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: