Deleting a large sized Confluence page having a sufficiently high count of historical versions can cause the Confluence process/JVM to run out of memory

XMLWordPrintable

    • 5
    • Severity 3 - Minor
    • 40

      Issue Summary

      For a page with a large enough payload (XHTML data) size and a sufficiently high count of historical versions, page deletion can overwhelm the allocated Java heap. Confluence can crash from that deletion attempt, leaving behind java.lang.OutOfMemoryError: Java heap space messages in the app logs:

      2025-06-12 17:02:45,318 ERROR [http-nio-8090-exec-6 url: /pages/doemptytrash.action; user: admin] [apache.struts2.dispatcher.DefaultDispatcherErrorHandler] sendErrorResponse Exception occurred during processing request: Method \"execute\" failed for object com.atlassian.confluence.pages.actions.EmptyTrashAction@191ac379
       -- url: /pages/doemptytrash.action | userName: admin | referer: http://localhost:8090/pages/emptytrash.action?key=ST | traceId: 7ac35ee6a2f17c2e
      ognl.MethodFailedException: Method "execute" failed for object com.atlassian.confluence.pages.actions.EmptyTrashAction@191ac379 [java.lang.OutOfMemoryError: Java heap space]
      Caused by: java.lang.OutOfMemoryError: Java heap space
      	at java.base/java.util.Arrays.copyOf(Arrays.java:3537)
      	at java.base/java.lang.String.<init>(String.java:574) 
      

      Deletion can happen in any of the following ways:

      • through the removal of the entire host space (BaseURL/spaces/doremovespace.action?key=<SPACE_KEY>)
      • moving the page to the space’s trash, and then purging it from trash (BaseURL/pages/purgetrashitem.action?key=<SPACE_KEY>&contentId=<ID_OF_LARGE_PAGE_WITH_MANY_VERSIONS>)
      • moving the page to space’s trash, and then emptying trash (BaseURL/pages/emptytrash.action?key=<SPACE_KEY>)

      Steps to Reproduce

      On a Confluence instance with say -Xmx4g (4 Gb Java heap):

      1. Create a large Confluence page (where its XHTML plain text storage size is say ~1+ Mb (larger sizes will result in faster failures)).
      2. Create thousands of versions of that page (say 4000+ versions).
      3. Click on the page’s top right corner, and then Delete to send the page to the host space’s trash (direct: BaseURL/pages/removepage.action?pageId=<ID_OF_LARGE_PAGE_WITH_MANY_VERSIONS>).
      4. Navigate to the host space’s trash by clicking on Space tools (bottom left) > Content tools > Trash (direct: BaseURL/pages/viewtrash.action?key=<SPACE_KEY>).
      5. Empty Trash (direct: BaseURL/pages/emptytrash.action?key=<SPACE_KEY>).
        This can also occur if:
        • the entire space (containing the large page with many versions) is deleted (BaseURL/spaces/doremovespace.action?key=<SPACE_KEY>), or
        • just that specific page is purged from the space’s trash (BaseURL/pages/purgetrashitem.action?key=<SPACE_KEY>&contentId=<ID_OF_LARGE_PAGE_WITH_MANY_VERSIONS>)
        • retention rules (for automatically removing trashed items after specific duration) purge the problematic page at some point

      Expected Results

      Page deletion to succeed without impacting app stability.

      Actual Results

      Confluence runs out of memory.

      Sample data extracted from a Confluence 9.5.1 instance with 4 Gb heap, with a page of size 1 Mb, with 4000 historical versions of that page, is given below.

      The browser will report an HTTP 500 System Error for the deletion attempt, along with an “Exception Request Unique ID” that can be searched in the atlassian-confluence.log):

      The atlassian-confluence.log will record a java.lang.OutOfMemoryError: Java heap space error:

      2025-06-12 17:02:45,318 WARN [http-nio-8090-exec-6 url: /pages/doemptytrash.action; user: admin] [confluence.impl.hibernate.ConfluenceHibernateTransactionManager] doRollback Performing rollback. Transactions:\n  ->[null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT (Session #1304172456)\n        [null]: PROPAGATION_REQUIRES_NEW,ISOLATION_DEFAULT (Session #1285481867)
       -- url: /pages/doemptytrash.action | userName: admin | referer: http://localhost:8090/pages/emptytrash.action?key=ST | traceId: 7ac35ee6a2f17c2e
      2025-06-12 17:02:45,318 ERROR [http-nio-8090-exec-6 url: /pages/doemptytrash.action; user: admin] [apache.struts2.dispatcher.DefaultDispatcherErrorHandler] sendErrorResponse Exception occurred during processing request: Method \"execute\" failed for object com.atlassian.confluence.pages.actions.EmptyTrashAction@191ac379
       -- url: /pages/doemptytrash.action | userName: admin | referer: http://localhost:8090/pages/emptytrash.action?key=ST | traceId: 7ac35ee6a2f17c2e
      ognl.MethodFailedException: Method "execute" failed for object com.atlassian.confluence.pages.actions.EmptyTrashAction@191ac379 [java.lang.OutOfMemoryError: Java heap space]
      Caused by: java.lang.OutOfMemoryError: Java heap space
      	at java.base/java.util.Arrays.copyOf(Arrays.java:3537)
      	at java.base/java.lang.String.<init>(String.java:574)
      ...
      2025-06-12 17:02:45,338 INFO [http-nio-8090-exec-6 url: /500page.jsp; user: admin] [atlassian.confluence.status.SystemErrorInformationLogger] writeToLog 
      ...
      Request Unique ID : dd6a4060-b4a6-4c1b-8c97-c4d8b29c8ab2
      ...
      URL: http://localhost:8090/500page.jsp
      ...
      javax.servlet.forward.request_uri: /pages/doemptytrash.action
      ...
      key : ST
      ...
      caused by: ognl.MethodFailedException: Method \"execute\" failed for object com.atlassian.confluence.pages.actions.EmptyTrashAction@191ac379 [java.lang.OutOfMemoryError: Java heap space]
      ...
      2025-06-12 17:02:45,338 ERROR [http-nio-8090-exec-6 url: /500page.jsp; user: admin] [atlassian.confluence.status.SystemErrorInformationLogger] logException Unhandled exception, request unique ID: dd6a4060-b4a6-4c1b-8c97-c4d8b29c8ab2
       -- traceId: 7ac35ee6a2f17c2e
      ognl.MethodFailedException: Method "execute" failed for object com.atlassian.confluence.pages.actions.EmptyTrashAction@191ac379 [java.lang.OutOfMemoryError: Java heap space]
      Caused by: java.lang.OutOfMemoryError: Java heap space
      	at java.base/java.util.Arrays.copyOf(Arrays.java:3537)
      	at java.base/java.lang.String.<init>(String.java:574)
      

      GC graphs (plotted using the Java GC logs) will show a rapid rise in heap usage until the configured heap limit is reached (black bars represent stop-the-world-full-GC events):

      If a heapdump is triggered (either manually or via the use of -XX:+HeapDumpOnOutOfMemoryError) while Confluence is attempting to delete the page, then the resulting heap file will show thousands of java.lang.String objects, each holding a historical version of that page, taking up a significant portion of the available heap.
      Heap overview:

      Leak Suspects report:

      Leak Suspects > Details view:

      Dominator tree view:

      Workaround

      Delete the historical versions manually (via REST API):

      curl --request DELETE --url 'BaseURL/rest/api/content/{id}/version/{versionNumber}' 
      

      To find Confluence page with the most versions, please refer to the following KB: Getting a list of Pages with most Historic Versions in Confluence Data Center

            Assignee:
            Anshul Chokhani
            Reporter:
            Mohit Sharma
            Votes:
            2 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: