tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filippo Machi <filippoma...@gmail.com>
Subject Re: Babysitting ThreadLocals
Date Wed, 23 Nov 2011 17:08:02 GMT
Ciao Christopher, i heard Joda has a thread safe date
parser/fotmatter..remember to check it doesn't use threadlocals too :)
Hth
Fil
Il giorno 23/nov/2011 17.57, "Christopher Schultz" <
chris@christopherschultz.net> ha scritto:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Chris,
>
> On 11/23/11 11:46 AM, chris derham wrote:
> > If you do this, and fine that creating these objects is taking more
> > time, then perhaps one method would be to use a weak object
> > reference to the thread local. That way you would get the best of
> > both worlds - no memory leak and reduced creation of
> > SimpleDateFormat.
>
> I hadn't thought of using a WeakReference. I wonder how often the GC
> would kill the reference between requests, though. We only get one
> maybe every 10 seconds or so right now, so it's possible that we'd
> have the memory churn associated with creating a new object for every
> request anyway.
>
> > However most people coding probably won't know what a ThreadLocal
> > class is/does, let alone a Weak memory reference. IMO it would be
> > easier just to code the easy way
>
> Yeah, this is definitely over-engineered at this point, especially
> given that it's not actually working the way it should (that is, we've
> got a memory leak).
>
> I think I'll look into the commons-lang date formatter to see if
> there's any reason to use it instead of SimpleDateFormat. If it
> performs reasonably under load (that is, doesn't have much in the way
> of synchronization and creates fewer objects than "new
> SimpleDateFormat") then I'll probably go with that... we already have
> a dependency on that library, anyway.
>
> Thanks,
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk7NJd4ACgkQ9CaO5/Lv0PBcwQCfaZ3OcDMwkgXRc6HIkNMF2ddM
> oHcAoLqaYghNBDFm3zIMS2mJSneRo3Fa
> =yw3K
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message