Memory Leak Detector from Logs
Parse allocation and free log lines and report every address that was allocated but never released, together with the leaked byte total.
Constraints
- Lines look like 'ALLOC 0x1000 64' or 'FREE 0x1000'.
- A FREE of an unknown address must be reported as a double free.
- Return a dict with leaks (address to size) and double_frees (list).
- Malformed lines are skipped silently.
- Must handle an address allocated, freed and allocated again.
1def find_leaks(lines):2 # TODO3 return {}