# Why is the memory on the server high, mostly in the db (mysqld) process, even though DB activity is not high?

**URL:** <https://forums.percona.com/t/why-is-the-memory-on-the-server-high-mostly-in-the-db-mysqld-process-even-though-db-activity-is-not-high/9680>\
**Category:** Percona Server for MySQL 5.7\
**Tags:** community, mysql, percona\
**Created:** [March 16, 2021, 12:33pm UTC](https://forums.percona.com/t/why-is-the-memory-on-the-server-high-mostly-in-the-db-mysqld-process-even-though-db-activity-is-not-high/9680 "2021-03-16T12:33:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fikri\_Maulana](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/fikri_maulana/32/3120_2.png) [@Fikri\_Maulana](https://forums.percona.com/u/Fikri_Maulana)\
**Post date:** [March 16, 2021, 12:33pm UTC](https://forums.percona.com/t/why-is-the-memory-on-the-server-high-mostly-in-the-db-mysqld-process-even-though-db-activity-is-not-high/9680/1 "2021-03-16T12:33:52Z")

</div>

You can see that the server memory is full,

 ![memory-cli](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/6/6d6632955da96fae0774e10e11d50c8ed98b5007.jpeg)

It can be seen from CLI monitoring that there are many mysql processes that use up to 10GB of memory (virtually), but in terms of DB activity itself is not heavy,

 ![db-resource-status](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/d/d47f55c46d0d3a882099d562fe9d85518a66fb00.png)

---

<div class="post-metadata">

**Author:** ![Fikri\_Maulana](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/fikri_maulana/32/3120_2.png) [@Fikri\_Maulana](https://forums.percona.com/u/Fikri_Maulana)\
**Post date:** [March 17, 2021, 10:28am UTC](https://forums.percona.com/t/why-is-the-memory-on-the-server-high-mostly-in-the-db-mysqld-process-even-though-db-activity-is-not-high/9680/2 "2021-03-17T10:28:07Z")

</div>

anyone can hellp me ?

---

<div class="post-metadata">

**Author:** ![mughees52](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mughees52/32/3156_2.png) [@mughees52](https://forums.percona.com/u/mughees52)\
**Post date:** [March 22, 2021, 9:23am UTC](https://forums.percona.com/t/why-is-the-memory-on-the-server-high-mostly-in-the-db-mysqld-process-even-though-db-activity-is-not-high/9680/3 "2021-03-22T09:23:43Z")

</div>

Hi @Fikri_Maulana short information about how MySQL uses memory

---

<div class="post-metadata">

**Author:** ![mughees52](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mughees52/32/3156_2.png) [@mughees52](https://forums.percona.com/u/mughees52)\
**Post date:** [March 22, 2021, 10:42am UTC](https://forums.percona.com/t/why-is-the-memory-on-the-server-high-mostly-in-the-db-mysqld-process-even-though-db-activity-is-not-high/9680/4 "2021-03-22T10:42:21Z")

</div>

@Fikri_Maulana  
short information about how MySQL uses memory. Check your innodb\_buffer\_pool\_size, The amount of memory u have assigned to MySQL will consume all of it,2nd thing which take place in memory consumption is Number thread/sessions running.  
From where to start memory consumption issues:

1. Check at Os level below command will give who is using most memory at OS level  
`ps -eo size,pid,user,command --sort -size | grep [m]ysqld | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }' |cut -d "" -f2 | cut -`d "-`" -f1`  
e.g my output was 799.32 Mb /usr/sbin/mysqld  
Or You can user TOP command aswell for specific process  
[root@localhost ~]# top -b -o %MEM -n1 -p 7392 | grep PID -A 1  
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND  
7392 mysql 20 0 1338008 350680 15308 S 0.0 14.8 0:04.45 mysqld  
7392 is our MySQL PID

2. below query will tell you which schema or temp tables are using your most of the memory  
\*SELECT SUBSTRING\_INDEX(event\_name,‘/’,2) AS code\_area, sys.format\_bytes(SUM(current\_alloc)) AS current\_alloc \*  
\*FROM sys.x$memory\_global\_by\_current\_bytes \*  
\*GROUP BY SUBSTRING\_INDEX(event\_name,‘/’,2) \*  
_ORDER BY SUM(current\_alloc) DESC;_
