Raffi,
When I'm developing new procedures, I'm pretty lavish with the
object creation, then once it's working, I go back over it to
eliminate the news. All of the void returns in Java 3D help
here, even though they practically encrypt my source code.
When I was working with complex data, I wrote an HP-style RPN
calculator stack that combined the memory pool idea with the
arithmetic and trig operations. Subjectively, it seemed to work
pretty well, the source was penetrable for anyone with a few
years dealing with RPN, but I never profiled any of it for speed
or memory use. The down side is that the space is permanently
allocated to the stack, but that's balanced by the upside of
very limited size even for complicated calculations (I used four
registers in a rotary stack.) I've been eyeing one nest of
current code that might benefit from the same sort of approach
with a Transform3D RPN stack. Maybe that'll be my spring
project.
Fred
----- Original Message -----
From: "Kasparian, Raffi J." <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, December 20, 2001 2:42 PM
Subject: [JAVA3D] Avoiding memory allocation and garbage
collection
> Hi all,
>
> In the interests of speeding up my J3D applications, I'm
considering the
> pros and cons of the following approach to avoiding memory
allocations and
> garbage collections. I have created a class called MemoryPool
that handles
> requests for Transform3Ds (for instance) by returning from a
pool of
> Transform3Ds an already created Transform3D that is no longer
in use. The
> calling method could use it and then return it back to the
pool of
> Transform3Ds free to be used again.
>
> public class MemoryPool{
>
> protected static final Stack transform3Ds = new Stack();
>
> static public Transform3D getTransform3D(){
> synchronized( transform3Ds ){
> if( transform3Ds.isEmpty() ){
> transform3Ds.push( new Transform3D() );
> }
> return (Transform3D)transform3Ds.pop();
> }
> }
> static public void returnTransform3D( Transform3D T ){
> transform3Ds.push( T );
> }
> }
>
> As an example of usage, the following method
>
> public doSomething(){
> Transform3D T = new Transform3D();//causes memory
allocation
> file://do something
> }//now eligible for garbage collection
>
> would be written as
>
> public doSomething(){
> Transform3D T = MemoryPool.getTransform3D();//no memory
allocation
> file://do something
> MemoryPool.returnTransform3D( T );//no garbage collection
> }
>
> Please, I am very interested in feedback.
>
> Thanks,
>
> Raffi
>
>
================================================================
===========
> To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body
> of the message "signoff JAVA3D-INTEREST". For general help,
send email to
> [EMAIL PROTECTED] and include in the body of the message
"help".
>
>
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".