@@ -284,7 +284,7 @@ private void initialize(Application application) {
284
284
if (jvm != null ) {
285
285
connection = getConnection (application );
286
286
if (connection != null ) {
287
- updateValues (System .currentTimeMillis ());
287
+ updateValues (System .currentTimeMillis (), getData () );
288
288
289
289
if (live ) {
290
290
monitoredDataListener = new MonitoredDataListener () {
@@ -294,9 +294,11 @@ public void monitoredDataEvent(final MonitoredData data) {
294
294
long timestamp = System .currentTimeMillis ();
295
295
final long timestampF = lastTimestamp < timestamp
296
296
? lastTimestamp = timestamp : ++lastTimestamp ;
297
+ final Object [] values = getData ();
298
+
297
299
SwingUtilities .invokeLater (new Runnable () {
298
300
public void run () {
299
- updateValues (timestampF );
301
+ updateValues (timestampF , values );
300
302
fireChange ();
301
303
}
302
304
});
@@ -323,25 +325,30 @@ private Object[] getAttributes(String... names) {
323
325
return null ;
324
326
}
325
327
326
- private void updateValues ( final long time ) {
328
+ private Object [] getData ( ) {
327
329
if (connection != null ) {
328
330
Object [] values = getAttributes (USAGE_ATTRIBUTE , PEAK_USAGE_ATTRIBUTE );
329
- if (values != null ) {
330
- CompositeData usageData = (CompositeData ) values [0 ];
331
- CompositeData peakData = (CompositeData ) values [1 ];
332
- if (usageData != null && peakData != null ) {
333
- MemoryUsage mem = MemoryUsage .from (usageData );
334
- MemoryUsage peak = MemoryUsage .from (peakData );
335
- heapUsed = mem .getUsed ();
336
- heapCapacity = peak .getUsed ();
337
- maxHeap = mem .getMax ();
338
- timestamp = time ;
339
- } else {
340
- connection = null ;
341
- }
342
- } else {
331
+
332
+ if (values == null ) {
343
333
connection = null ;
344
334
}
335
+ return values ;
336
+ }
337
+ return null ;
338
+ }
339
+
340
+ private void updateValues (final long time , Object [] values ) {
341
+ if (values != null ) {
342
+ CompositeData usageData = (CompositeData ) values [0 ];
343
+ CompositeData peakData = (CompositeData ) values [1 ];
344
+ if (usageData != null && peakData != null ) {
345
+ MemoryUsage mem = MemoryUsage .from (usageData );
346
+ MemoryUsage peak = MemoryUsage .from (peakData );
347
+ heapUsed = mem .getUsed ();
348
+ heapCapacity = peak .getUsed ();
349
+ maxHeap = mem .getMax ();
350
+ timestamp = time ;
351
+ }
345
352
}
346
353
}
347
354
0 commit comments