Merge "profiling: Fix cleanup of profiling state."
diff --git a/src/profiling/memory/socket_listener.cc b/src/profiling/memory/socket_listener.cc
index 733c6ea..654fe4e 100644
--- a/src/profiling/memory/socket_listener.cc
+++ b/src/profiling/memory/socket_listener.cc
@@ -26,6 +26,8 @@
if (it != process_info_.end()) {
ProcessInfo& process_info = it->second;
process_info.sockets.erase(self);
+ if (process_info.sockets.empty())
+ process_info_.erase(it);
} else {
PERFETTO_DFATAL("Disconnect from socket without ProcessInfo.");
}