in memory_analyzer/analysis_utils.py [0:0]
def snapshot_diff(cur_items, snapshot_file):
"""
Attempts to compare like PIDs. If like PIDS can't be found it will just compare
the first PID listed to the first PID in the file. Any unmatched or non-first
PIDs will be ignored because we don't know what to compare them to.
"""
try:
prev_items = list(frontend_utils.get_pages(snapshot_file))
except pickle.UnpicklingError as e:
frontend_utils.echo_error(
f"Error unpickling the data from {snapshot_file}: {e}"
)
return None
differences = []
for cur_item in cur_items:
for prev_item in prev_items:
if cur_item.pid == prev_item.pid:
diff = summary.get_diff(cur_item.data, prev_item.data)
differences.append(
RetrievedObjects(
pid=cur_item.pid,
title=f"Snapshot Differences for {cur_item.pid}",
data=diff,
)
)
if not differences:
diff = summary.get_diff(cur_items[0].data, prev_items[0].data)
differences.append(
RetrievedObjects(pid=0, title=f"Snapshot Differences", data=diff)
)
return differences