pluginaweek/state_machine — Issue #152: Excessive memory usage in rails
Author: stevestmartin
Created: 2012-01-03 00:30:19+00:00
State: open

We were seeing large amounts of CPU time spent in GC mainly due to object allocation when generating the call stack in NilClass#raise_nil_warning_for in ActiveSupport's whiny_nil implementation.

I tracked it back to initializing [callbacks](https://github.com/pluginaweek/state_machine/blob/master/lib/state_machine/callback.rb#L129) where it is apparently calling

```ruby
Array(nil)
```

triggering a

```ruby
nil.to_ary
```

causing the exception (which i think are just being swallowed). While this issue is mainly do to the whiny_nil implementation which is being removed from future rails versions, simply changing

```ruby
Array(options.delete(:do))
```

to

```ruby
Array(options.delete(:do) || [])
```
would remove the issue for everyone.