I was having a problem with the MySQL adapter for Ruby throwing a stack and memory trace when the script was finished running. The script ran fine and from the error below, you can see it’s related to the garbage collection, or lack thereof, that the MySQL adapter is doing.
Here’s the error I got:
*** glibc detected *** ruby: double free or corruption (!prev): 0x09bb64b8 ***
======= Backtrace: =========
The application I was working no longer needed to connect to the database so I put the problem off until I came across it again today. After some research I looked for alternatives to the old adapter, but there was nothing.
Then I came across a post by Stefan Kaes, “Make ruby-mysql create less garbage“. He had found a problem with the amount of objects the adapter created and that was leading to a performance hit.
I thought perhaps the problem I was having would be fixed by applying his patch. It certainly couldn’t hurt anything, right? Who doesn’t want a faster database adapter?
After downloading the patch and applying it on my server, I rebuilt the mysql 2.7 adapter and POW!
Problem solved. Many thanks to Stefan.