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));
}
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);
}
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));
}
Aggregations