libsnapshot:snapuserd: Cut down memory usage

Use sorted std:vector instead of std:map to store
the mapping between chunk-id to COW operation.

Addtionally, use shrink_to_fit to cut down vector
capacity when COW operations are stored.

On a full OTA of 1.8G, Anon RSS usage is
reduced from 120MB to 68MB.  No variance observed
when merge was in progress.

Bug: 182960300
Test: Full and Incremental OTA - verified memory usage
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I50cacbe0d03837a830dedcf9bd0ac9663fc68fa7
4 files changed