Skip to content
Snippets Groups Projects
Commit 69cf85d8 authored by Jean Chalard's avatar Jean Chalard Committed by Android (Google) Code Review
Browse files

Merge "Fix a large native memory leak."

parents 8b833071 3f675f70
No related branches found
No related tags found
No related merge requests found
......@@ -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() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment