On Fri, 19 Jan 2024 05:40:02 GMT, David Holmes <dhol...@openjdk.org> wrote:

> I also wonder if we should be looking at a different way to track j.u.c lock 
> usage, as searching the full heap does not seem at all reasonable.

Good question. It looks like bin/jstack does the same, but there is much less 
cost to doing this within hotspot than with using SA:


void ConcurrentLocksDump::dump_at_safepoint() {
  // dump all locked concurrent locks
  assert(SafepointSynchronize::is_at_safepoint(), "all threads are stopped");

  GrowableArray<oop>* aos_objects = new (mtServiceability) 
GrowableArray<oop>(INITIAL_ARRAY_SIZE, mtServiceability);

  // Find all instances of AbstractOwnableSynchronizer
  
HeapInspection::find_instances_at_safepoint(vmClasses::java_util_concurrent_locks_AbstractOwnableSynchronizer_klass(),
                                              aos_objects);
  // Build a map of thread to its owned AQS locks
  build_map(aos_objects);

  delete aos_objects;
}

-------------

PR Comment: https://git.openjdk.org/jdk/pull/17479#issuecomment-1899810567

Reply via email to