Search in sources :

Example 1 with HeapSample

use of io.flutter.perf.HeapMonitor.HeapSample 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 HeapSample

use of io.flutter.perf.HeapMonitor.HeapSample in project flutter-intellij by flutter.

the class HeapState method paintComponent.

@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    if (heapState == null) {
        return;
    }
    final int height = getHeight() - 1;
    final int width = getWidth();
    final long now = System.currentTimeMillis();
    final int maxDataSize = Math.round(heapState.getMaxHeapInBytes() / TEN_MB) * TEN_MB + TEN_MB;
    final Graphics2D graphics2D = (Graphics2D) g;
    graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    graphics2D.setColor(getForegroundColor());
    graphics2D.setStroke(GRAPH_STROKE);
    Path2D path = null;
    for (HeapSample sample : heapState.getSamples()) {
        final double x = width - (((double) (now - sample.getSampleTime())) / ((double) heapState.getMaxSampleSizeMs()) * width);
        // TODO(pq): consider a Y offset or scaling.
        final double y = (double) height * sample.getBytes() / maxDataSize;
        if (path == null) {
            path = new Path2D.Double();
            path.moveTo(x, height - y + 1);
        } else {
            path.lineTo(x, height - y + 1);
        }
    }
    graphics2D.draw(path);
}
Also used : Path2D(java.awt.geom.Path2D) HeapSample(io.flutter.perf.HeapMonitor.HeapSample)

Example 3 with HeapSample

use of io.flutter.perf.HeapMonitor.HeapSample 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)

Aggregations

HeapSample (io.flutter.perf.HeapMonitor.HeapSample)3 HeapSpace (io.flutter.perf.HeapMonitor.HeapSpace)2 IsolateObject (io.flutter.perf.HeapMonitor.IsolateObject)1 Path2D (java.awt.geom.Path2D)1