Update mem module to count allocations and deletions for a lightweight form of leak detection