"B. Craig Taverner" wrote:

> Hi,
>
> I'm dealing with a performance issue in java where it appears that
> performance is noticably affected by the fact that many (thousands) of
> relatively small objects need to be created very quickly (multiple small
> memory allocations). From my C/C++ background I would have considered
> solving this problem by allocating the objects in reasonable sized blocks
> of objects (single alloc for many objects to minimize system calls).
> Individual objects could still be accessed (perhaps
> calloc/sizeof/typecast) and could then continue to be referenced in the
> normal way (hashtables, vectors, trees, etc).
>
> However, I do not see any obvious way to achieve this in java.  You cannot
> simply allocate a chunk of memory (you also cannot know the object size,
> or typecaste the memory to the object type).  If I allocate an array of
> objects, I'm simply allocating an array object that contains references to
> the correct object type, but does not actually contain those objects, and
> they still need to be created.
>
> Does anyone know of a good way to solve this problem?  Any suggestions
> around the issue of object creation performance are welcome.

One way to handle this problem would be to create an Object pool.
There was an article on javaworld (www.javaworld.com) a few months
back.  Basically, instead of creating new objects you request them from the
pool.  When they are not needed anymore, you put them back in the pool.  This

way the GC won't collect them.
The pool must be able to "clean up" objects and so on...
begin:vcard
n:Trussart;Vincent
x-mozilla-html:TRUE
org:Université de Montréal
adr:
version:2.1
email;internet:[EMAIL PROTECTED]
note:ICQ# 4357910
x-mozilla-cpt:;-28736
fn:Vincent Trussart
end:vcard

Reply via email to