Search in sources :

Example 1 with HeapSpace

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));
}
Also used : HeapSample(io.flutter.perf.HeapMonitor.HeapSample) IsolateObject(io.flutter.perf.HeapMonitor.IsolateObject) HeapSpace(io.flutter.perf.HeapMonitor.HeapSpace)

Example 2 with HeapSpace

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));
}
Also used : HeapSample(io.flutter.perf.HeapMonitor.HeapSample) HeapSpace(io.flutter.perf.HeapMonitor.HeapSpace)

Example 3 with HeapSpace

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;
}
Also used : IsolateRef(org.dartlang.vm.service.element.IsolateRef) HeapListener(io.flutter.perf.HeapMonitor.HeapListener) HeapSpace(io.flutter.perf.HeapMonitor.HeapSpace) JBLabel(com.intellij.ui.components.JBLabel) VM(org.dartlang.vm.service.element.VM) List(java.util.List)

Aggregations

HeapSpace (io.flutter.perf.HeapMonitor.HeapSpace)3 HeapSample (io.flutter.perf.HeapMonitor.HeapSample)2 JBLabel (com.intellij.ui.components.JBLabel)1 HeapListener (io.flutter.perf.HeapMonitor.HeapListener)1 IsolateObject (io.flutter.perf.HeapMonitor.IsolateObject)1 List (java.util.List)1 IsolateRef (org.dartlang.vm.service.element.IsolateRef)1 VM (org.dartlang.vm.service.element.VM)1