Possible it has meaning to pool array objects, but I believe JVM handles momory fragmentation better.
----- Original Message ----- From: "Gary Gregory" <[EMAIL PROTECTED]> To: "'Jakarta Commons Developers List'" <[EMAIL PROTECTED]> Sent: Wednesday, March 12, 2003 7:06 PM Subject: RE: [lang] ObjectUtils interner? > The test provide some interesting data but as Strings support being > intern'ed in the JRE (String.intern()), using Strings as an example is > probably not the best choice unless you want to pool String Objects outside > of the String class intern pool. > > Gary > > -----Original Message----- > From: Juozas Baliuka [mailto:[EMAIL PROTECTED] > Sent: Wednesday, March 12, 2003 8:28 AM > To: Jakarta Commons Developers List > Subject: Re: [lang] ObjectUtils interner? > > > trivial test: > > > final int iterations = 100000; > long time = System.currentTimeMillis(); > > for(int i =0; i< iterations ; i++){ > String s = new String("A"); > } > > System.out.println( "inren " + (System.currentTimeMillis() - time) ); > > time = System.currentTimeMillis(); > for(int i =0; i< iterations ; i++){ > char s[] = new char[]{'A'}; > } > > System.out.println( "new " + (System.currentTimeMillis() - time) ); > > > output: > > inren 140 > new 21 > > String pooling doe's not helps for me, but possible this test is wrong . > > ----- Original Message ----- > From: "Gary Gregory" <[EMAIL PROTECTED]> > To: "'Jakarta Commons Developers List'" <[EMAIL PROTECTED]> > Sent: Wednesday, March 12, 2003 3:35 PM > Subject: RE: [lang] ObjectUtils interner? > > > > >1) A mechanism for pooling Integers, Floats, Doubles, etc. as they are > > >created, to conserve memory. > > > > As someone else noted, objects created by running this util code could > itelf > > create extra objects that would nullify benefits of such memory savings. > In > > my work I try not to spend time providing performance/memory improvements > > until I have measured a specific bottleneck (with JProbe or simply > > System.currentTimeMillis()). Yes, in theory, something like this could be > > quite useful and I can imagine scenarios where gobs of Integers are needed > > but I would personally not bother until I have proven to myself that my > > bottleneck is creating Integers (or Floats, or whatever). > > > > Furthermore, doesn't an Object "interner" sounds like it belongs in Pool > > more than in Lang? > > > > Gary > > > > -----Original Message----- > > From: Stephen Colebourne [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, March 11, 2003 3:57 PM > > To: Jakarta Commons Developers List > > Subject: Re: [lang] ObjectUtils interner? > > > > > > Any views on this one? > > > > It seems like a sensible addition to ObectUtils. (Although I'm not sure of > > the exact use it would be. Hmmm) > > > > Stephen > > > > ----- Original Message ----- > > From: "Rich Dougherty" <[EMAIL PROTECTED]> > > To: "Jakarta Commons Developers List" <[EMAIL PROTECTED]> > > Sent: Tuesday, March 11, 2003 11:31 PM > > Subject: Re: [lang] Pooled and mutable numbers. > > > > >1) A mechanism for pooling Integers, Floats, Doubles, etc. as they are > > >created, to conserve memory. For example, instead of having: > > > > Here's a fun little class. It is inspired by the String.intern() method. > > > > import java.util.WeakHashMap; > > import java.util.Map; > > > > public class Interner { > > > > private Map internedObjects = new WeakHashMap(); > > > > public Interner() { > > } > > > > public Object intern(Object object) { > > Object internedObject = internedObjects.get(object); > > if (internedObject == null) { > > internedObjects.put(object, object); > > return object; > > } else { > > return internedObject; > > } > > } > > > > } > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]