sxross/MotionModel — pull request #100 by torben (2014-01-11 21:06:11+00:00)
Title: Fixed memory issue with NSDataDetector

Hi @sxross,

After a long time using your Gem, I've just found a memory issue, when you creating a bunch of records with a string as date.

You can easily reproduce it:

Open your instruments tool with a activity monitor; Sorting after memory. Then build an application with a MotionModel named "animal". Add a field like "born_at" with :time as type.
Rake and paste this into your REPL:

for i in 1..200
a = Animal.new
a.born_at = "2012-12-12 12:12:12"
sleep 0.3 # With the sleep command you can see the memory growing...
end

Then you can see, that every model wants to have ~12 MB of the memory. The iPhone will crash after a while.

In my case I have fixed it with a class variable @detector. Maybe it is better to use a singleton? What are you thinking about that?

Thanks again for your hard work on this gem

Torben