Article View: borland.public.jbuilder.java.language
Article #18374Re: Strategy for Object Reusing
From: Gerry Mantha
Date: Fri, 03 Jul 1998 00:00
Date: Fri, 03 Jul 1998 00:00
39 lines
2322 bytes
2322 bytes
Hi William, check this out: http://www.javaworld.com/javaworld/jw-06-1998/jw-06-object-pool.html Here you should find all you need to get started. This one's a very popular way of re-using objects in Java. Reusing objects is also great for increasing performance! Gerry Mantha William Yu wrote in message <359CBFDC.DE310722@Bigfoot.com>... >After going off on an tangent in another newsgroup, I got to thinking >about the problem with memory heap compaction. Currently, the JVM does >not return compacted memory back to the OS. That means an application >that runs 24x7 will continually grab more memory until the OS halts the >JVM with an error. (This has been reported in NT, SunOS and Linux.) >Until JavaSoft fixes this (bug fix planned for 1.2beta4), we have to >very meticulously resuse objects for 24x7 applications. I'd like to >explore the best way of implement a recycler class. I already have >something in my application but it's very ugly and I prefer to rip it >out and replace it with code that's more elegant and flexible. > >My initial idea is to base the recycler class on a static vector. Use >the vector like a stack -- objects no longer needed at added to the end >of the vector. When creating objects, instead of using "new" to >instantiate objects, pop an object off and populate (or reset) the data >fields. The devil, of course, is in the details. What's your take on >where the responsibility to maintain these recycling stacks belong. >Should each class implementing the recycler interface maintain a >separate stack? Or should there be a "super-recycler" that can maintain >stacks for everybody? > >BTW, is there anyway to get the current date/time without creating a new >object? This would allow me to recycle Date objects when I need current >time.
Technical Details
Message-ID:
<6njkh0$9sj10@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<359CBFDC.DE310722@Bigfoot.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,463db4f771a2408f X-Google-Attributes: gidf74b3,public From: "Gerry Mantha" <gmantha@home.com> Subject: Re: Strategy for Object Reusing Date: 1998/07/03 Message-ID: <6njkh0$9sj10@forums.borland.com> X-Deja-AN: 368518995 References: <359CBFDC.DE310722@Bigfoot.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.1 Organization: QTECH Hybrid Systems Inc. Newsgroups: borland.public.jbuilder.java.language