Claus Ibsen created CAMEL-23870:
-----------------------------------

             Summary: Add HeapHistogram dev console and TUI panel for 
class-level memory analysis
                 Key: CAMEL-23870
                 URL: https://issues.apache.org/jira/browse/CAMEL-23870
             Project: Camel
          Issue Type: Improvement
          Components: camel-jbang, camel-core
            Reporter: Claus Ibsen


Add a new dev console that exposes a JVM class histogram from the running Camel 
application, and a corresponding TUI panel to visualize it.

h3. Dev Console: HeapHistogramDevConsole

A new dev console (e.g. jvm/heap-histogram) that uses DiagnosticCommandMBean to 
invoke gcClassHistogram inside the running JVM:

{code:java}
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
ObjectName name = new ObjectName("com.sun.management:type=DiagnosticCommand");
String histogram = (String) server.invoke(name, "gcClassHistogram",
    new Object[]{null}, new String[]{"[Ljava.lang.String;"});
{code}

This returns the same output as {{jcmd <pid> GC.class_histogram}} but runs 
inside the target JVM through the dev console - no external jcmd access needed. 
This fits the existing pattern used by MemoryDevConsole and JvmDevConsole.

The JSON response should include:
* Array of class entries: class name, instance count, total bytes
* Top N classes by default (e.g. top 50) to keep response size manageable
* Option to trigger a full GC before collecting (live objects only)
* Summary totals

h3. TUI Panel

A new tab (accessible via More menu) showing the class histogram as a sortable 
table:
* Columns: class name, instance count, total bytes
* Sortable by any column (default: bytes descending)
* Search/filter support
* Complements the existing Memory tab which shows aggregate heap/GC stats but 
not what is consuming the heap

h3. Use Case

When investigating memory issues in a running Camel integration, users 
currently see heap totals in the Memory tab but cannot determine *what* is 
consuming the heap without attaching an external tool like VisualVM or MAT. The 
class histogram gives immediate visibility into the largest consumers directly 
from the TUI.

h3. Reference

The boot-ui project (https://github.com/jdubois/boot-ui) has a similar Heap 
Dump panel that captures and analyzes heap dumps showing class histograms 
(names and sizes only, never object values).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to