Skip to content

Commit 15b1cd7

Browse files
committed
Memory Sampler improvements
- Copy context menu action - customizable context menu of Heap sampler - UI unified with the other profiling views
1 parent 8f93990 commit 15b1cd7

File tree

5 files changed

+878
-1128
lines changed

5 files changed

+878
-1128
lines changed

visualvm/sampler/src/com/sun/tools/visualvm/sampler/SamplerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ public void takeHeapDump(boolean openView) {
751751
else hds.takeRemoteHeapDump(application, null, openView);
752752
}
753753
};
754-
memorySampler = new MemorySamplerSupport(jvm, hasPermGenHisto, threadsMemory, memoryBean, snapshotDumper, heapDumper) {
754+
memorySampler = new MemorySamplerSupport(application, jvm, hasPermGenHisto, threadsMemory, memoryBean, snapshotDumper, heapDumper) {
755755
protected Timer getTimer() { return SamplerImpl.this.getTimer(); }
756756
};
757757
SwingUtilities.invokeLater(new Runnable() {

visualvm/sampler/src/com/sun/tools/visualvm/sampler/memory/Bundle.properties

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,21 @@ LBL_PermGen_histogram=PermGen histogram
3030

3131
LBL_ThreadAlloc=Per thread allocations
3232

33-
COL_Class_name=Class Name
33+
COL_Class_name=Name
3434

3535
COL_Bytes_rel=Bytes [%]
3636

37-
COL_Bytes=Bytes
37+
COL_Bytes=Live Bytes
3838

3939
COL_ABytes_rel=Allocated Bytes [%]
4040

4141
COL_ABytes=Allocated Bytes
4242

43-
COL_ABytes_Sec=Allocated Bytes/sec
43+
COL_ABytes_Sec=Allocated Bytes / sec
4444

45-
COL_Instances=Instances
45+
COL_Instances=Live Objects
4646

47-
COL_Thread_name=Thread Name
47+
COL_Thread_name=Name
4848

4949
TOOLTIP_Pause_results=Pause live results
5050

visualvm/sampler/src/com/sun/tools/visualvm/sampler/memory/MemorySamplerSupport.java

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
package com.sun.tools.visualvm.sampler.memory;
2727

28+
import com.sun.tools.visualvm.application.Application;
2829
import com.sun.tools.visualvm.application.jvm.HeapHistogram;
2930
import com.sun.tools.visualvm.application.jvm.Jvm;
3031
import com.sun.tools.visualvm.core.options.GlobalPreferences;
@@ -54,6 +55,8 @@
5455
*/
5556
public abstract class MemorySamplerSupport extends AbstractSamplerSupport {
5657

58+
private final Application application;
59+
5760
private final Jvm jvm;
5861
private final MemoryMXBean memoryBean;
5962
private final ThreadsMemory threadsMemory;
@@ -77,7 +80,9 @@ public abstract class MemorySamplerSupport extends AbstractSamplerSupport {
7780

7881
private DataViewComponent.DetailsView[] detailsViews;
7982

80-
public MemorySamplerSupport(Jvm jvm, boolean hasPermGen, ThreadsMemory mem, MemoryMXBean memoryBean, SnapshotDumper snapshotDumper, HeapDumper heapDumper) {
83+
public MemorySamplerSupport(Application application, Jvm jvm, boolean hasPermGen, ThreadsMemory mem, MemoryMXBean memoryBean, SnapshotDumper snapshotDumper, HeapDumper heapDumper) {
84+
this.application = application;
85+
8186
this.jvm = jvm;
8287
hasPermGenHisto = hasPermGen;
8388
threadsMemory = mem;
@@ -94,12 +99,22 @@ public DataViewComponent.DetailsView[] getDetailsView() {
9499
}
95100
heapView.initSession();
96101
if (permgenView != null) permgenView.initSession();
102+
if (threadAllocView != null) threadAllocView.initSession();
97103
return detailsViews.clone();
98104
}
99105

100106
public boolean startSampling(ProfilingSettings settings, int samplingRate, int refreshRate) {
101107
// heapTimer.start();
102108
// permgenTimer.start();
109+
110+
SwingUtilities.invokeLater(new Runnable() {
111+
public void run() {
112+
if (heapView != null) heapView.starting();
113+
if (permgenView != null) permgenView.starting();
114+
if (threadAllocView != null) threadAllocView.starting();
115+
}
116+
});
117+
103118
heapRefresher.setRefreshRate(samplingRate);
104119
if (permgenRefresher != null)
105120
permgenRefresher.setRefreshRate(samplingRate);
@@ -113,6 +128,14 @@ public boolean startSampling(ProfilingSettings settings, int samplingRate, int r
113128
}
114129

115130
public synchronized void stopSampling() {
131+
SwingUtilities.invokeLater(new Runnable() {
132+
public void run() {
133+
if (heapView != null) heapView.stopping();
134+
if (permgenView != null) permgenView.stopping();
135+
if (threadAllocView != null) threadAllocView.stopping();
136+
}
137+
});
138+
116139
heapTimer.stop();
117140
if (permgenTimer != null) {
118141
permgenTimer.stop();
@@ -126,8 +149,13 @@ public synchronized void stopSampling() {
126149
}
127150

128151
public synchronized void terminate() {
129-
if (heapView != null) heapView.terminate();
130-
if (permgenView != null) permgenView.terminate();
152+
SwingUtilities.invokeLater(new Runnable() {
153+
public void run() {
154+
if (heapView != null) heapView.terminated();
155+
if (permgenView != null) permgenView.terminated();
156+
if (threadAllocView != null) threadAllocView.terminated();
157+
}
158+
});
131159
}
132160

133161

@@ -224,12 +252,12 @@ private DataViewComponent.DetailsView[] createViews() {
224252
if (threadAllocRefresher != null) detailsCount++;
225253
DataViewComponent.DetailsView[] details = new DataViewComponent.DetailsView[detailsCount];
226254

227-
heapView = new MemoryView(heapRefresher, MemoryView.MODE_HEAP, memoryBean, snapshotDumper, heapDumper);
255+
heapView = new MemoryView(application, heapRefresher, MemoryView.MODE_HEAP, memoryBean, snapshotDumper, heapDumper);
228256
details[detailIndex++] = new DataViewComponent.DetailsView(
229257
NbBundle.getMessage(MemorySamplerSupport.class, "LBL_Heap_histogram"), // NOI18N
230258
null, 10, heapView, null);
231259
if (hasPermGenHisto) {
232-
permgenView = new MemoryView(permgenRefresher, MemoryView.MODE_PERMGEN, memoryBean, null, heapDumper);
260+
permgenView = new MemoryView(application, permgenRefresher, MemoryView.MODE_PERMGEN, memoryBean, null, heapDumper);
233261
details[detailIndex++] = new DataViewComponent.DetailsView(
234262
NbBundle.getMessage(MemorySamplerSupport.class, "LBL_PermGen_histogram"), // NOI18N
235263
null, 20, permgenView, null);

0 commit comments

Comments
 (0)