Bayou City Leaks
I grew up in the Houston area and most of my family still lives there,
so it was fun to do a presentation in the
is the president of the Houston Java Users Group (HJUG)
and when I got
in touch with him several weeks ago I provided a list of about six
topics on which I would be happy to do a presentation.
Jim put that list to a vote and the winner was my talk on tracking
down memory leaks
in Java applications. I originally did this
presentation at JavaOne
last year and have repeated it at
TheServerSide Java Symposium.
It changes around a bit each time. The biggest addition was in July of this
year for the TheServerSide conference in Barcelona:
I added a whole section on permanent generation memory
leaks, based on the work of Frank Kieviet and
Edward Chou. Frank and Edward did an
earlier this year at JavaOne dedicated entirely to that topic.
Frank and I also collaborated with Sundar on an
article about permanent
generation memory leaks for Software Test & Performance magazine.
Another change that I made last night was to include a demo of
VisualVM, a relatively new
tool that is being developed as an open source project.
There is an introductory document available on the project web site. I hope to write more about VisualVM soon.
The changes I have made to the presentation have also been driven by
the questions that I have gotten when doing the presentation. A consistent
theme that was repeated last night in Houston was: "Is there a way to prevent
memory leaks from occurring in the first place?"
Automating detection is a problem. Tom Ball
left a comment on that topic on my
post from JavaZone. There are, however, some things that can be automated.
If, for example, you are shadowing
a static variable with a local variable
and as a result you do not end up setting the static variable to null and a memory leak
results, then a good editor
or FindBugs can point
out to you that you are
shadowing the variable. But detecting that the shadowing indirectly leads to a memory leak
is beyond the capability of any static analysis tool that I know of.
There are best practices that can certainly help. (For example, don't shadow
static variables with local variables :-) ) I probably need to
add a section on weak references to this presentation - I got a question specifically about that
last night. My favorite post on that topic is from Ethan Nicholas:
Understanding Weak References.
Some photos are below.
The pizza was popular, as usual.
The room is not too big and not too small.
Left to right: Paul Lisowski, Stephen Nimmo, Gregg Sporar, Jim Bethancourt