Memory Release Issues in TiDB Components

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 关于tidb组件内存释放问题

| username: zhanggame1

[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version]
[Reproduction Path] What operations were performed to encounter the issue
[Encountered Issue: Problem Phenomenon and Impact]
Recently, during testing, we found that some SQL queries cause the TiDB process to occupy a large amount of memory. After the SQL execution is complete, the occupied memory is not released immediately and takes some time. The question is, is there any pattern to the memory release of the TiDB process when it occupies a large amount of memory, or are there any parameters to control the release speed?

| username: linnana | Original post link

DC recycling defaults to every 10 minutes.

| username: zhanggame1 | Original post link

What is DC, is it GC? That one is for TiKV.

| username: linnana | Original post link

Typed wrong :blush: it’s GC

| username: zhanggame1 | Original post link

GC is a disk operation for Region, I am asking about the memory usage of the TiDB component.

| username: redgame | Original post link

There isn’t a good solution, we usually break down the SQL.

| username: cassblanca | Original post link

Recently, I found that some SQL queries cause the TiDB process to occupy a large amount of memory. After the SQL execution is complete, the occupied memory is not released immediately and takes some time. Is there any pattern to the memory release of the TiDB process, or are there any parameters to control the release speed?

During the execution of SQL statements in TiDB, to improve performance, a certain amount of memory is sometimes pre-allocated. After the SQL statement execution is complete, this pre-allocated memory is not released immediately but is retained for a period of time. You can try several parameters like tikv-buffer-size, tikv-buffer-pool-size, and tikv-buffer-pool.

| username: Kongdom | Original post link

I remember it won’t be released immediately.