Java Performance Services
Training, Seminars, Benchmarking, Tuning

Java Performance Tuning Course


Chania Crete, May 17-20, 2010


Sun Extreme Learning EXL-2025

Houston, December 1-4,2009
New York, December 8-11, 2009
Washington DC, January 5-8, 2010



San Francisco, January 11-14

Anti-if

I have joined Anti-IF Campaign

Calendar

««Nov 2009»»
SMTWTFS
1234
5
67
891011121314
15161718192021
22232425262728
2930

Performance Anti-Patterns

My Top Tags

                                       

Mailing List

My RSS Feeds








Send me your memory leaks

posted Wednesday, 7 February 2007
At this years JavaPolis I endeavored to have the audience work through a performance tuning exercise during our University session. In planning for this session I fretted over just how hard a problem I should give. In the process of setting the level of difficulty I came to the conclusion that the difficulty was not with the problem but rather with the tools I was using (I used quite a few different ones including the usual suspects).

What I was looking for was a reliable way to locate the leak using a set of instructions that I could give to my mother (ok,, maybe not that simple but...). Problem was, it just wasn't happening and I didn't want to stand up in front of 300+ people and say, to diagnose a memory leak you need to perform some black magic. Unfortunately this is just about what I did during that session. So, since then I've been doing a lot of thinking about the problem. I've also had some interesting conversations on the subject with a number of people and know have some idea's I'd like to try out.

The true test is; can I find the leak with minimal interaction with the code. I.E. I want to do this using instrumentation only looking to the code at the end of the exercise. So, I'd like to try it out on a few use cases. If you have or had a particularly nasty memory leak in your Java application, I'd be interested in hearing from you. I should add that any derived technique will end up in the public domain.

tags:      




1. Rickard left...
Thursday, 8 February 2007 1:09 pm

One of my favourites involve threadlocals. I found this one in Struts 2.0, but the problem is pretty general. If you have a threadlocal in a webapp which stores some context for each request, and this is populated by for example a servlet filter, then it is vital that the threadlocal is cleared when the request is done. What might otherwise happen is that a redeploy of the webapp will not release the previous version, since there is a reference in a threadlocal.

Solution: always clear your threadlocal contexts when you're done, and always do this in a finally clause to ensure that is always done.


2. Sergey Zeltnysh left...
Wednesday, 14 March 2007 1:39 pm

Hi Kirk,

I think i understand what you mean. Here's my perspective on that.

I had a bit of trouble grasping your puzzlers in Cologne. It's not because of puzzlers, the presentation was really good, it was because of me.

First I am eclipse user. Not idea. But ok. Idea has some nice colours too. So I was all excited to crack all the puzzlers myself and win the prizes =)

And then..... you had, upon request from the audience, copy and paste the code from nice Idea editor to b/w notepad. You lost me from then on.... =)

My case is only one case of course. We all have habits of thinking. Some don't have to 'stick' to screen (like the guys who won the prizes), some need to 'stick' to mouse and keyboard to just start understanding the code..

So it might be quite challanging to cover most kinds of minds =)

-- Sergey