Mysql-ruby gem using significantly more memory that mysql.rb?

I have found that, using the mysql-ruby gem leads to 40 MB more memory
consumption in my tests than plain mysql.rb.

Is anyone aware of this?

My test loads a nasty grid of values using many include statements
which result in about 5000 rows being returned (the actual number of
rows is much less but the joins increase the number).

When using ruby-mysql:
The memory usage jumps from ~75megs to 161megs after executing
result.all_hashes and does not go back down.

When using mysql.rb:
The memory usage jumps from ~75megs to 121megs after executing
result.all_hashes and does not go back down.

I have two major concerns…

1.) why doesn’t the process eventually release the memory that is used
up? I am destroying all references to the grid and calling GC.start to
be sure
2.) why does ruby-mysql use significantly more memory than mysql.rb?

I appreciate any help and will continue investigating on my own in the
mean time.

(I already posted this in the core list, but realized that since I
don’t have a fix yet and since mysql-ruby is outside of rails it would
probably be more appropriate here.)

Thanks,
Kris

Hi Kris,

I have found that, using the mysql-ruby gem leads to 40 MB more memory
consumption in my tests than plain mysql.rb.

Is anyone aware of this?

Yeah, MySQL/Ruby is known to create an overly amount of garbage. Stefan
Kaes has a patch for it [1] and I provide a compiled set of MySQL/Ruby
adapters for Windows that have got this patch [2].

[1]
https://railsexpress.de/blog/articles/2006/10/05/make-ruby-mysql-create-less-garbage
[2] http://www.vandomburg.net (currently migrating to another host;
adapters will be back up soon)


Roderick van Domburg
http://www.nedforce.com

On Nov 7, 2007 11:35 PM, SillyDude [email protected]
wrote:

1.) why doesn’t the process eventually release the memory that is used
up? I am destroying all references to the grid and calling GC.start to
be sure

GC returns the memory to the internal free pool, but the memory is
never returned to the operating system. This isn’t a Ruby-specific
thing; most programs work the same way. The only way to accomplish
that is to have the program re-exec itself.