use of io.flutter.perf.HeapMonitor.HeapSpace in project flutter-intellij by flutter.
the class HeapState method handleIsolatesInfo.
@Override
public void handleIsolatesInfo(VM vm, List<IsolateObject> isolates) {
int current = 0;
int total = 0;
isolateHeaps.clear();
for (IsolateObject isolate : isolates) {
isolateHeaps.put(isolate.getId(), isolate.getHeaps());
for (HeapSpace heap : isolate.getHeaps()) {
current += heap.getUsed() + heap.getExternal();
total += heap.getCapacity() + heap.getExternal();
}
}
rssBytes = vm.getJson().get("_currentRSS").getAsInt();
heapMaxInBytes = total;
addSample(new HeapSample(current, false));
}
use of io.flutter.perf.HeapMonitor.HeapSpace in project flutter-intellij by flutter.
the class HeapState method handleGCEvent.
@Override
public void handleGCEvent(IsolateRef isolateRef, HeapSpace newHeapSpace, HeapSpace oldHeapSpace) {
int current = 0;
isolateHeaps.put(isolateRef.getId(), new ArrayList<>(Arrays.asList(newHeapSpace, oldHeapSpace)));
for (List<HeapSpace> heaps : isolateHeaps.values()) {
for (HeapSpace heap : heaps) {
current += heap.getUsed() + heap.getExternal();
}
}
addSample(new HeapSample(current, true));
}
use of io.flutter.perf.HeapMonitor.HeapSpace in project flutter-intellij by flutter.
the class HeapState method createJPanelView.
public static JPanel createJPanelView(Disposable parentDisposable, FlutterApp app) {
final JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP));
panel.setPreferredSize(new Dimension(100, PANEL_HEIGHT));
final JBLabel rssLabel = new JBLabel();
rssLabel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
rssLabel.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
rssLabel.setForeground(UIUtil.getLabelDisabledForeground());
rssLabel.setBorder(JBUI.Borders.empty(4));
final JBLabel heapLabel = new JBLabel("", SwingConstants.RIGHT);
heapLabel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
heapLabel.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
heapLabel.setForeground(UIUtil.getLabelDisabledForeground());
heapLabel.setBorder(JBUI.Borders.empty(4));
final HeapState heapState = new HeapState(60 * 1000);
final HeapDisplay graph = new HeapDisplay(state -> {
rssLabel.setText(heapState.getRSSSummary());
heapLabel.setText(heapState.getHeapSummary());
SwingUtilities.invokeLater(rssLabel::repaint);
SwingUtilities.invokeLater(heapLabel::repaint);
});
graph.setLayout(new BoxLayout(graph, BoxLayout.X_AXIS));
graph.add(rssLabel);
graph.add(Box.createHorizontalGlue());
graph.add(heapLabel);
panel.add(graph, BorderLayout.CENTER);
final HeapListener listener = new HeapListener() {
@Override
public void handleIsolatesInfo(VM vm, List<IsolateObject> isolates) {
heapState.handleIsolatesInfo(vm, isolates);
graph.updateFrom(heapState);
SwingUtilities.invokeLater(panel::repaint);
}
@Override
public void handleGCEvent(IsolateRef iIsolateRef, HeapSpace newHeapSpace, HeapSpace oldHeapSpace) {
heapState.handleGCEvent(iIsolateRef, newHeapSpace, oldHeapSpace);
graph.updateFrom(heapState);
SwingUtilities.invokeLater(panel::repaint);
}
};
assert app.getPerfService() != null;
app.getPerfService().addListener(listener);
Disposer.register(parentDisposable, () -> app.getPerfService().removeListener(listener));
return panel;
}
Aggregations