Weak is Good

3 12 2006

I’ve been giving Ruby and JRuby all the love lately, but tonight is Java’s night:

A Java program, if reasonably well designed, can be a joy to maintain.

I spent the last couple of days hunting down a memory leak in our server app. Finding the memory leak really sucked, but here’s where it gets good. The leak was in a single object, used for caching. Fixing it involved replacing the standard collections with WeakReference based collections. Since the program used the Collections interfaces, I only had to change the instantiations. That’s it. Game over.

Now, since the program is reasonably well designed, there are unit tests available, so I can verify that my fix didn’t break anything else. Also, now that the garbage collector is able to get its job done, the application seems to be performing better (and, of course, not crashing).

Weak is Good.

Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: