Daniel's Stuff

I write code

Category: Ruby

JRuby, Rails and Development mode

Well, that was fun…  I spent quite a bit of time today beating my head against a “memory leak” only to remember that JRuby + Rails + Development mode = very leaky.  Switch to production mode and the problem goes away.

A simple little Rails app with one controller and one model is all that is needed to exercise the problem.  Run rails in development mode, and hit it with requests, memory usage soon skyrockets and the app starts to fall over.  Switch to production mode and the same app runs really nicely πŸ™‚

FreeTDS and my new Mac Pro

I’ve been having some “fun” with my new Mac Pro.  In order for me to be able to use it for my daily work I need to be able to connect to a Microsoft SQL Server instance from the Rails app I’m working on at my day job.  Normally this is just a simple matter of installing FreeTDS, Ruby-ODBC and the Ruby DBI and DBD packages.  When I did this, as soon as I tried to make a connection to the SQL Server instance my application would crash with a bus error!  After a bit of digging around with gdb I discovered that the application was crashing when FreeTDS was trying to deallocate a string using the standard C library memory function free.  The really weird thing is that the string was pointing to a valid string.  I dug a little further and found that if I changed the code that was allocating the string to use malloc and strcpy instead of strdup it worked!  If anybody out there knows why this might make a difference I’d really like to hear from them about it.