do flushUntrackedMemory when context swith

This commit is contained in:
Sema Checherinda 2023-03-01 18:16:03 +01:00
parent 20bebf7a16
commit a6c2473518
4 changed files with 12 additions and 3 deletions

View File

@ -129,8 +129,7 @@ void CurrentThread::flushUntrackedMemory()
if (current_thread->untracked_memory == 0)
return;
current_thread->memory_tracker.adjustWithUntrackedMemory(current_thread->untracked_memory);
current_thread->untracked_memory = 0;
current_thread->flushUntrackedMemory();
}
}

View File

@ -144,6 +144,12 @@ ThreadStatus::ThreadStatus()
#endif
}
void ThreadStatus::flushUntrackedMemory()
{
memory_tracker.adjustWithUntrackedMemory(untracked_memory);
untracked_memory = 0;
}
ThreadStatus::~ThreadStatus()
{
memory_tracker.adjustWithUntrackedMemory(untracked_memory);

View File

@ -290,6 +290,8 @@ public:
void logToQueryViewsLog(const ViewRuntimeData & vinfo);
void flushUntrackedMemory();
protected:
void applyQuerySettings();

View File

@ -352,8 +352,10 @@ void ThreadStatus::detachQuery(bool exit_if_already_detached, bool thread_exits)
thread_group->threads.erase(this);
}
performance_counters.setParent(&ProfileEvents::global_counters);
memory_tracker.reset();
flushUntrackedMemory();
memory_tracker.reset();
memory_tracker.setParent(thread_group->memory_tracker.getParent());
query_id.clear();