Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8355636

Reuse StringBuilder in printStackTrace

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • 25
    • 24
    • core-libs
    • None

      In the Throwable::printStackTrace method, StringBuilder is created multiple times to build String. By sharing StringBuilder to build String, object allocation and copying are reduced.

      In the scenario without suppressed and ourCause, unused IdentityHashMap is not created.

      Through these optimizations, the performance of new Exception().printStackTrace() can be improved by about 10%.

            Unassigned Unassigned
            swen Shaojin Wen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: