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

Incorrect weight of the first ObjectAllocationSample JFR event (regression)

XMLWordPrintable

    • jfr
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Tested on multiple JDKs, 17, 21, 24, 25, seems to affect all versions.

      A DESCRIPTION OF THE PROBLEM :
      When capturing an allocation profile, the first ObjectAllocationSample events have an incorrect weight (they are including allocations from before the start of the capture).

      This seems to be a regression of JDK-8307488, however after testing with several JDKs, I cannot find a version where it was actually fixed.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      The reproducer attached to issue JDK-8307488 still reproduces the issue: https://bugs.openjdk.org/browse/JDK-8307488

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expected to not see the first ObjectAllocationSample event have a such a large weight of ~2GB; it should be much lower, as well as reporting the correct class / line where the allocation occurred.
      ACTUAL -
      First allocation from the profile is 2GB:

      jdk.ObjectAllocationSample {
        startTime = 10:34:06.286 (2025-07-17)
        objectClass = java.lang.Object (classLoader = bootstrap)
        weight = 2.0 GB
        eventThread = "main" (javaThreadId = 3)
        stackTrace = [
          WrongAllocationWeight.main(String[]) line: 28
        ]
      }

      It's also attributed to the wrong line / class.

      ---------- BEGIN SOURCE ----------
      See test case / reproducer attached to JDK-8307488: https://bugs.openjdk.org/browse/JDK-8307488
      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: