Sun's Gregg Sporar presented at JavaMUG tonight on memory leaks. We had a really good crowd, about 58 people.

The biggest thing I picked up from the presentation is why there would ever even be any memory leaks - because I would never write any in my programs, of course. So I had to learn how others might write leaks that I would be asked to fix. :)  Never lie, either, except in this blog.

The memory leaks that Gregg demo'd in his story wouldn't have happened to me because I am a simpleton in my approach to java.

Proof of my wimpy java habits:

  • I just don't use threads unless someone points a gun to my head, which has only happened once, I'm just too scared of side effects. Even in that one situation,  I made Michael Nash do it, he's always much smarter than me anyway.
  • On a similar vein, I stay away from static class members almost entirely, because they make my head hurt. Singletons with a getInstance() being the one common exception, a poor man's "service" when I don't whoop out Spring instead.

What Gregg was quck to point out was you don't always write the memory leaks that defeat you, and he demonstrated a Java 1.2 Swing bug that got him on one of his projects, and he showed how and where. So I was wrong, I could have memory leaks in my programs, because I use external libraries.

All in all, It was very helpful to get a nice view of what could happen and why, and the three main approaches on how to figure it out after it happened.

I also learned that 

  • I need to learn about Weak References (something I had never even heard of until tonight).
  • Increased my general distrust of all static class members
  • Affirmed my resolution to just never use threads unless I reeeeeeeaallly knew what I was doing, or was willing to take the time to research Doug Lea's patterns for one to apply, before I started.

His presentation is put on line here and he has some fantastic references for both tools and approaches. In addition to what is reviewable there he mentioned verbally tools he could not put in his presentation since he's a Netbeans evangelist.

This was one of our best presentions in recent memory. Very informative, concise, and with easy to understand stories and code samples. Thanks Gregg !

This is what the announcement looked like.