@@ -55,6 +55,7 @@ final class ProfilerSnapshotNPS extends ProfilerSnapshot {
55
55
56
56
private static final Logger LOGGER = Logger .getLogger (ProfilerSnapshotNPS .class .getName ());
57
57
private LoadedSnapshot loadedSnapshot ;
58
+ private FileObject snapshotFO ;
58
59
private TopComponent srw ;
59
60
60
61
ProfilerSnapshotNPS () {
@@ -63,26 +64,26 @@ final class ProfilerSnapshotNPS extends ProfilerSnapshot {
63
64
64
65
ProfilerSnapshotNPS (File snapshot , DataSource master ) {
65
66
super (snapshot , master );
66
- FileObject fobj = FileUtil .toFileObject (FileUtil .normalizeFile (snapshot ));
67
- loadedSnapshot = ResultsManager .getDefault ().loadSnapshot (fobj );
67
+ snapshotFO = FileUtil .toFileObject (FileUtil .normalizeFile (snapshot ));
68
68
}
69
69
70
70
@ Override
71
- public LoadedSnapshot getLoadedSnapshot () {
71
+ public synchronized LoadedSnapshot getLoadedSnapshot () {
72
+ if (loadedSnapshot == null )
73
+ loadedSnapshot = ResultsManager .getDefault ().loadSnapshot (snapshotFO );
72
74
return loadedSnapshot ;
73
75
}
74
76
75
77
@ Override
76
78
protected void remove () {
77
79
super .remove ();
78
- ResultsManager .getDefault ().closeSnapshot (loadedSnapshot );
79
-
80
+ closeSnapshot ();
80
81
}
81
82
82
83
@ Override
83
84
protected Image resolveIcon () {
84
85
try {
85
- int snapshotType = getLoadedSnapshot ().getType ( );
86
+ int snapshotType = ResultsManager . getDefault ().getSnapshotType ( snapshotFO );
86
87
switch (snapshotType ) {
87
88
case LoadedSnapshot .SNAPSHOT_TYPE_CPU :
88
89
return ImageUtilities .mergeImages (CPU_ICON , NODE_BADGE , 0 , 0 );
@@ -106,7 +107,7 @@ protected Image resolveIcon() {
106
107
@ Override
107
108
JComponent getUIComponent () {
108
109
if (srw == null ) {
109
- srw = SnapshotResultsWindow .get (loadedSnapshot , CommonConstants .SORTING_COLUMN_DEFAULT , false );
110
+ srw = SnapshotResultsWindow .get (getLoadedSnapshot () , CommonConstants .SORTING_COLUMN_DEFAULT , false );
110
111
srw .setPreferredSize (new Dimension (1 , 1 ));
111
112
112
113
DataSource master = getMaster ();
@@ -150,4 +151,9 @@ public void run() {
150
151
});
151
152
}
152
153
}
154
+
155
+ private synchronized void closeSnapshot () {
156
+ ResultsManager .getDefault ().closeSnapshot (loadedSnapshot );
157
+ loadedSnapshot = null ;
158
+ }
153
159
}
0 commit comments