views:

48

answers:

4

I have a new Ubuntu Linux Server 64bit 10.04 LTS.

A default install of Mysql with replication turned on appears to be leaking memory. However, we've tried going back to an earlier version and memory is still leaking but I can't tell where.

What tools/techniques can I use to pinpoint where memory is leaking so that I can rectify the problem?

A: 

Try using valgrind.

ninjalj
+3  A: 

Valgrind, http://valgrind.org/, can be very useful in these situations. It runs on unmodified executables but it does help tremendously if you can install the debugging symbols. Be sure to use the --show-reachable=yes flag as the leaked memory may still be reachable in some way but just not the way you want it. Also --trace-children in case of a fork. You'll likely have to track down in the start-up script where the executable is called and then add something like the following:

 valgrind --show-reachable=yes --trace-children=yes --log-file=/path/to/log SQL-cmdline sqlargs

The man page has lots of other potentially useful options.

Have you tried the MySQL mailing list? Something like this would certainly be of interest to them if you can reproduce it in a straightforward manner.

Paul Rubel
A: 

A very good and powerful tool, which is installed/available for most distributions is Valgrind.

It has a plethora of different options and is pretty much (as far as I've seen) the default profiler under linux systems.

MadcapLaugher
+1  A: 

You can use Valgrind as ninjalj suggests, but I doubt you'll get that close to anything useful. Even if you see a real leak (and they will be hard enough to validate), tracking down the root cause through the C call stacks will likely be very annoying (for example if the leak is triggered by a particular SQL pattern or stored procedure, you'll be looking at the call stack from the resultant optimized query, and not the original calls, which are likely in a different language).

Normally you might have no recourse, and have to resort to tracking it down through callstacks and iterative testing, but you have the source code to MySQL (including the source for the exact default package install), so you can use more advanced tools like MemoryScape (or at least build with symbols in order to provide Valgrind more food for thought).

Nick Bastin