summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-04-16 16:18:33 +0900
committerJean Chalard <jchalard@google.com>2012-04-16 16:48:53 +0900
commit3f675f70601575a2964a3a4f5d8fcd639446238d (patch)
tree5ec43acb95a2dcf4676c4ef275d8fbd50f322878 /native
parenta7352c8df48476ead4a469c89e2d976241e25589 (diff)
downloadandroid_packages_inputmethods_LatinIME-3f675f70601575a2964a3a4f5d8fcd639446238d.tar.gz
android_packages_inputmethods_LatinIME-3f675f70601575a2964a3a4f5d8fcd639446238d.tar.bz2
android_packages_inputmethods_LatinIME-3f675f70601575a2964a3a4f5d8fcd639446238d.zip
Fix a large native memory leak.
This leak was about 500k and would happen whenever a new binary dictionary was opened/closed. Bug: 6299535 Change-Id: I4fad5b4d9c556ca889f5ef62d9d083a2eff6346a
Diffstat (limited to 'native')
-rw-r--r--native/jni/src/words_priority_queue_pool.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/native/jni/src/words_priority_queue_pool.h b/native/jni/src/words_priority_queue_pool.h
index 5b50e8f4f..210b5a848 100644
--- a/native/jni/src/words_priority_queue_pool.h
+++ b/native/jni/src/words_priority_queue_pool.h
@@ -26,6 +26,7 @@ namespace latinime {
class WordsPriorityQueuePool {
public:
WordsPriorityQueuePool(int mainQueueMaxWords, int subQueueMaxWords, int maxWordLength) {
+ // Note: using placement new() requires the caller to call the destructor explicitly.
mMasterQueue = new(mMasterQueueBuf) WordsPriorityQueue(mainQueueMaxWords, maxWordLength);
for (int i = 0, subQueueBufOffset = 0;
i < MULTIPLE_WORDS_SUGGESTION_MAX_WORDS * SUB_QUEUE_MAX_COUNT;
@@ -36,6 +37,11 @@ class WordsPriorityQueuePool {
}
virtual ~WordsPriorityQueuePool() {
+ // Note: these explicit calls to the destructor match the calls to placement new() above.
+ if (mMasterQueue) mMasterQueue->~WordsPriorityQueue();
+ for (int i = 0; i < MULTIPLE_WORDS_SUGGESTION_MAX_WORDS * SUB_QUEUE_MAX_COUNT; ++i) {
+ if (mSubQueues[i]) mSubQueues[i]->~WordsPriorityQueue();
+ }
}
WordsPriorityQueue* getMasterQueue() {