summaryrefslogtreecommitdiff
path: root/osi
diff options
context:
space:
mode:
authorSrinu Jella <sjella@codeaurora.org>2015-11-06 14:59:10 +0530
committerAndre Eisenbach <eisenbach@google.com>2016-03-14 08:59:45 -0700
commit2bea757aba0d0d84865d7d0d675d8bcf31f90b22 (patch)
tree75a6e0a32fafa78033087384be01845985160e7c /osi
parentfecf606348a0751e0be30e376c9817195afe68ca (diff)
downloadandroid-system-bt-2bea757aba0d0d84865d7d0d675d8bcf31f90b22.tar.gz
android-system-bt-2bea757aba0d0d84865d7d0d675d8bcf31f90b22.tar.xz
Free allocation tracker hash map entries to reduce memory pressure
Use case: A2DP playback becomes choppy after long hours of testing. Steps: 1. installed 3rd party app that performs recurring LE scans. 2. Leave phone to run overnight. 3. After 24h+, connect a Bluetooth headset and music is very choppy. Root cause: The memory allocation tracker has support for double free check where it stores all allocations in hash map but it never get removed to track double free issue, A2DP memory allocation is taking more time and leading to choppyness. Fix: Free the hash map entry to avoid memory leak from allocation tracker. Bug: 27621407 Change-Id: If57bd0b89c1d9b99c4f066c537a9e0fa49bc093f
Diffstat (limited to 'osi')
-rw-r--r--osi/src/allocation_tracker.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/osi/src/allocation_tracker.c b/osi/src/allocation_tracker.c
index 1815be9..b4e1a84 100644
--- a/osi/src/allocation_tracker.c
+++ b/osi/src/allocation_tracker.c
@@ -167,6 +167,11 @@ void *allocation_tracker_notify_free(UNUSED_ATTR uint8_t allocator_id, void *ptr
assert(end_canary[i] == canary[i]);
}
+ // Free the hash map entry to avoid unlimited memory usage growth.
+ // Double-free of memory is detected with "assert(allocation)" above
+ // as the allocation entry will not be present.
+ hash_map_erase(allocations, ptr);
+
pthread_mutex_unlock(&lock);
return ((char *)ptr) - canary_size;