JDK-8289318 : JDWP: defer enabling ObjectFree events for class tracking until CLASS_UNLOAD events are requested
  • Type: Enhancement
  • Component: core-svc
  • Sub-Component: debugger
  • Affected Version: 20
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2022-06-28
  • Updated: 2024-07-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
During reviewing JDK-8256811, [~cjplummer] has following comments (https://github.com/openjdk/jdk/pull/9168#discussion_r907812755)
"This looked a bit strange to me w.r.t. when we activate class tracking, so I looked into it. It turns out that when the debugger sends a request for CLASS_UNLOAD events, we convert it to EI_GC_FINISH and install a handler for it (and activate class tracking as you see in the above code). Activating doesn't do much. In fact it's not even where the ObjectFree events are enabled. This is done unconditionally in `classTrack_initialize()`, which is called whenever the debug agent is initialized.  This means we always have the ObjectFree events enabled, even when the debugger has not requested CLASS_LOAD events. This seems like a bit of a performance issue. Maybe `classTrack_activate()` is where we should be enabling ObjectFree events.  We should probably file a separate CR to have this fixed"
Comments
My comment was in reference to the following code (which is now removed): src/jdk.jdwp.agent/share/native/libjdwp/eventHandler.c: 1712: if (node->ei == EI_GC_FINISH) { 1713: classTrack_activate(getEnv()); 1714: } We were "activating" class tracking when the debugger requested CLASS_UNLOAD events, which the debug agent translates into GC_FINISH since that's when it generates CLASS_UNLOAD events. However, classTrack_activate() did very little (and now it is gone). The real "activating" is done by classTrack_initialize(), which tags all Class instances and enables JVMTI ObjectFree events for them. Unfortunately this is all done unconditionally when the debug agent is initialized, so we are always tracking loaded classes, even when it is unnecessary because there is no CLASS_UNLOAD event request from the debugger. We could be smarter about when we initialize class tracking, which would help performance and memory footprint.
29-06-2022