use of com.android.tools.idea.monitor.ui.memory.model.MemoryPoller in project android by JetBrains.
the class MemoryProfilerUiManager method setupExtendedOverviewUi.
@Override
public void setupExtendedOverviewUi(@NotNull JPanel toolbar, @NotNull JPanel overviewPanel) {
super.setupExtendedOverviewUi(toolbar, overviewPanel);
assert myPollerSet != null;
myTriggerHeapDumpButton = new JButton(AndroidIcons.Ddms.DumpHprof);
MemoryPoller poller = (MemoryPoller) Iterables.getOnlyElement(myPollerSet);
myTriggerHeapDumpButton.addActionListener(e -> {
if (poller.requestHeapDump()) {
myEventDispatcher.getMulticaster().profilerExpanded(ProfilerType.MEMORY);
}
});
toolbar.add(myTriggerHeapDumpButton, HorizontalLayout.LEFT);
myAllowAllocationTracking = true;
myAllocationTrackerButton = new JToggleButton(AndroidIcons.Ddms.AllocationTracker, false);
myClient.enableAllocationTracker(false);
myAllocationTrackerButton.addActionListener(e -> {
boolean selected = myAllocationTrackerButton.isSelected();
if (selected) {
if (!myAllowAllocationTracking) {
myAllocationTrackerButton.setSelected(false);
return;
}
myAllowAllocationTracking = false;
myClient.enableAllocationTracker(true);
final long startTime = TimeUnit.NANOSECONDS.toMicros(myDataStore.mapAbsoluteDeviceToRelativeTime(TimeUnit.MICROSECONDS.toNanos(myDataStore.getLatestTimeUs())));
AndroidDebugBridge.addClientChangeListener(new AndroidDebugBridge.IClientChangeListener() {
@Override
public void clientChanged(@NonNull Client client, int changeMask) {
if (client == myClient && (changeMask & Client.CHANGE_HEAP_ALLOCATIONS) != 0) {
final byte[] data = client.getClientData().getAllocationsData();
final long endTime = TimeUnit.NANOSECONDS.toMicros(myDataStore.mapAbsoluteDeviceToRelativeTime(TimeUnit.MICROSECONDS.toNanos(myDataStore.getLatestTimeUs())));
UIUtil.invokeLaterIfNeeded(() -> {
myEventDispatcher.getMulticaster().profilerExpanded(ProfilerType.MEMORY);
if (myProject.isDisposed()) {
return;
}
if (myDataCache != null) {
myDataCache.addAllocationTrackingData(new AllocationTrackingSample(startTime, endTime, data));
}
});
myAllowAllocationTracking = true;
AndroidDebugBridge.removeClientChangeListener(this);
}
}
});
} else {
myClient.requestAllocationDetails();
myClient.enableAllocationTracker(false);
}
myAllocationTrackerButton.updateUI();
});
toolbar.add(myAllocationTrackerButton, HorizontalLayout.LEFT);
}
use of com.android.tools.idea.monitor.ui.memory.model.MemoryPoller in project android by JetBrains.
the class MemoryProfilerUiManager method createPollers.
@NotNull
@Override
public Set<Poller> createPollers(int pid) {
myDataCache = new MemoryDataCache(myMemoryEventDispatcher);
MemoryPoller poller = new MemoryPoller(myDataStore, myDataCache, pid);
Map<SeriesDataType, DataAdapter> adapters = poller.createAdapters();
for (Map.Entry<SeriesDataType, DataAdapter> entry : adapters.entrySet()) {
// TODO these need to be de-registered
myDataStore.registerAdapter(entry.getKey(), entry.getValue());
}
if (myMemoryDetailView != null) {
myMemoryDetailView.notifyDataIsReady(myDataCache);
}
return Sets.newHashSet(poller);
}
Aggregations