Bug #32041 tiny memory leak if example udf is loaded and unloaded
Submitted: 2 Nov 2007 2:31 Modified: 23 Mar 2009 18:43
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: User-defined functions ( UDF ) Severity:S3 (Non-critical)
Version:5.1.23-debug, 5.1, 6.0 bzr OS:Any (MS Windows, Linux)
Assigned to: CPU Architecture:Any
Tags: memory leak
Triage: Triaged: D2 (Serious)

[2 Nov 2007 2:31] Shane Bester
Description:
When loading and unloading the example udf in a loop, the server's memory usage continues to rise.

In my test so far, 9.7 million loops consumed roughly ~400MB of memory in the server process.

How to repeat:
#do this a few million times in a loop.  leave it for some hours:

drop function metaphon;
create metaphon returns string soname 'udf_example.dll';

Suggested fix:
Run under valgrind and find the leak if it exists.
[2 Nov 2007 10:02] Shane Bester
typo. meant this:

drop function metaphon;
create function metaphon returns string soname 'udf_example.dll';
[23 Mar 2009 18:43] Sveta Smirnova
Thank you for the report.

Verified as described.

Test case:

--source include/have_udf.inc

--eval create function metaphon returns string soname "$UDF_EXAMPLE_LIB"

--disable_query_log
let $i=1000000;
while ($i)
{
drop function metaphon;
--eval create function metaphon returns string soname "$UDF_EXAMPLE_LIB"
dec $i;
}
--enable_query_log

select 1;

Options:

$UDF_EXAMPLE_LIB_OPT

Then examine memory usage while test is running.
[31 Jan 2013 10:06] Shane Bester
still leaks memory on mysql-trunk !
[28 Apr 2016 8:51] Shane Bester
still affects current 5.8.0-dmr