Skip to content

java memory management, oh my!

How much do you understand basic java? Every day I find some part of this language that I’m not aware of, or don’t understand. Some days it’s cool APIS (like JAI) but today it’s concurrency. Now, language managed memory is a feature that’s been present in the languages in which I’ve been programming since I started. I’ve looked at C and C++, but taking a job coding in those seems to me it’d be like a job with a long commute–both have obstacles keeping you from getting real work done. (I’m not alone in feeling this way.) But this thread of comments on Cameron Purdy’s blog drove home my ignorance. However, the commenters do point out several interesting articles (in particular, this article about double checked locking was useful and made my head hurt at the same time) to alleviate that. I took a class with Tom Cargill a few years back, which included his threading module, that helped a bit.

However, all these complexities are why servlets (and EJBs) are so powerful. As long as you’re careful to only use local variables, why, you shouldn’t have to worry about threading at all. That’s what you use the container for, right? And we all know that containers are bug free, right? And you’d never have to go back and find some isolated thread related defect that affected your code a maddeningly miniscule amount of time, right?

5 thoughts on “java memory management, oh my!

  1. Kris Thompson says:

    You missed a great BJUG awhile back on nothing but the JVM memory management. It was amazing! The basic take away was unless you REALLY know what you are doing, don’t manually screw around wiht the garabage collector, memory flags to the JVM and other memory stuff because you will most likely make things worse.

  2. Dion Almaer says:

    Interesting point regarding servlets and EJBs. Some people argue that the threading restriction in EJB is dumb, as:

    – No one uses SingleThreadModel in their Servlets, and this is even an anti-pattern 🙂

    – You sometimes need to get down and dirty in enterprise apps. It is annoying that you can’t play nice. Give me a way to get a thread from the app server (so it can still manage them) so I can play!

    The new concurrency API (from Doug Leas util.concurrency) in JDK 1.5 is awesome too 🙂

    Dion

  3. Dan Moore says:

    Actually, I was there (I loved his analogy about throwing burger wrappers out of the window) and it highlighted how little I knew, and how much JVM tuning was a dark art. Profile, profile, profile (on the production hardware, mind you) and empirically determine what works best seemed to be his prescription.

    I wish BJUG would post past presentations on their website (http://www.boulderjug.org), because I’d love to review what Simon Roberts said.

  4. Glenn Mason says:

    This isn’t the right entry to add this to, but a while back you mentioned something about javadeps – dependency checking for java (based on more than modification timestamps).

    It’s interesting, because it checks class dependencies by looking at the byte code (not parsing the source), so it’s apparently quite quick.

    Cheers!

Comments are closed.