After a recent upgrade to Ruby 2.1.0 I noticed a significant increase in memory usage when using hashes of any size when clearing the hashes before inserting.
To test this behaviour I repeatedly (10x) filled in 1 million different string keys, each with a nil value.
Results:
With Ruby 1.9.3, RSS used stays mostly constant (to 157952 when clearing before inserting).
With Ruby 2.1.0, RSS used grows far more rapidly when the Hash is cleared before inserting (to 241972, mostly right after refilling for the first time), but also jumps up once when this is not done.
This difference is probably due to addition of the generational garbage collector introduced in Ruby 2.1, in combination with the specifics of the malloc implementation you are using. hashmemtest2 is expected to perform worse as you are resizing the hash on each iteration, as opposed to hashmemtest1, which does not change the hash size after the first iteration.
For hashmemtest1.rb with ruby 2.1 in my environment: