Bug #22849 MySQL does not free memory when MEMORY table is dropped
Submitted: 29 Sep 2006 23:16 Modified: 7 Dec 2006 13:13
Reporter: Haralambos Marmanis Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:Ver 14.12 Distrib 5.1.11-beta OS:Linux (Linux 2.6.9-5.EL smp #1 )
Assigned to: CPU Architecture:Any

[29 Sep 2006 23:16] Haralambos Marmanis
Description:
cat /procs/meminfo  (or use top)

Write down the free memory

Create a large memory (heap) table (a few GB).

drop the table

cat /procs/meminfo (or use top)

Look at the free memory, it is not back at the level that it was before. It seems that the memory that had been allocated is not released after you drop the table.

You probable use free() and that is OS implementation dependent.
The code was compiled with gcc

gcc (GCC) 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)

The obvious workaround is, of course, to reboot the server

How to repeat:
Just follow the description. People have reported a similar problem on Solaris and MySQL 4.x. 

Suggested fix:
The obvious workaround is, of course, to reboot the server
[7 Nov 2006 13:13] Valeriy Kravchuk
Thank you for a problem report. Please, check the results of

free

before and after that action. For huge MEMORY table temporary table on disk may be created, and it can be just cached in filesystem cache.

In case of any doubts, please, check with a newer version, 5.1.12, and send your my.cnf content.
[8 Dec 2006 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[16 Mar 2009 16:45] Felix Oghina
I confirm this bug on 5.0.67 on my Ubuntu Server 8.10 system (so MySQL version 5.0.67-0ubuntu6, if that has any importance).
I had a couple of big tables (together ~1.85GB) in MEMORY and DROPped them, but I can still see the mysqld process using 2GB (in top).
Drop me an e-mail if you need my my.cnf -- znupi69 @at@ gmail point. com