I'm trying to track down a memory leak in the state_machine gem that I began to notice when I started dynamically generating state machines using anonymous classes per the README example. This gist demonstrates how I uncovered the issue originally.
I've been able to narrow down the problem to the way helper methods get defined in the state machine gem which I've summarized in this gist.
My question is, what is the define_method
block doing that causes the anonymous class not to get garbage collected? Commenting those 3 lines (18-20) seems to solve the issue.
Thanks in advance for any pointers.
Update: I'm using Ruby 2.0.0p195