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

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.