# HOWTO release SWAP back to OS the right way

**URL:** <https://forums.percona.com/t/howto-release-swap-back-to-os-the-right-way/7006>\
**Category:** Other MySQL® Questions\
**Created:** [May 9, 2019, 5:16pm UTC](https://forums.percona.com/t/howto-release-swap-back-to-os-the-right-way/7006 "2019-05-09T17:16:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mysql.girl](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mysql.girl/32/29_2.png) [@mysql.girl](https://forums.percona.com/u/mysql.girl)\
**Post date:** [May 9, 2019, 5:16pm UTC](https://forums.percona.com/t/howto-release-swap-back-to-os-the-right-way/7006/1 "2019-05-09T17:16:07Z")

</div>

Hi ALL, I have a master that is alerting for using up my SWAP space,  
usually I add another swap file to extend the swap footprint.  
or restart mysql - but since this is a Master I don’t want to disrupt the serveries  
Q:  
Is there another way?  
I tried swapoff -a and swapon -a but it give me an error : not enough free memory to do this  
.  
I then noticed the box has 256GB RAM and only 120GB was set in innodb\_buffer\_pool\_size  
Since this variable is dynamic in 5.7  
I upped it to 160GB on Wednesday and upped it again to 200GB on Thursday.  
mysql\> set global innodb\_buffer\_pool\_size=164_1024_1024_1024  
mysql\> set global innodb\_buffer\_pool\_size=200_1024_1024_1024

See pictures below  
I then ran  
FLUSH TABLES ;  
RESET QUERY CACHE ;

Q:  
Shouldn’t that flush out everything from the mysql memory and release the memory back?

I am now able to run swapoff -a  
but it has been sitting there for hours w/o giving me back the command prompt.  
Swap: 4095 3377 718  
Swap: 3219 3219 0  
Swap: 3209 3209 0  
Swap: 2623 2623 0  
Swap: 1834 1834 0

But I see the swap is being flushed out and is coming down…  
I guess it will come down to Zero swap and then give back the prompt  
and I can then turn on the Swap again swapon -a
