Sign in to follow this  
hashi

Pooling. What is worth it, what is not.

Recommended Posts

I have Class constructor that require options parameter, that parameter is plainobject {}, also it has 0 or more arrays inside and another plainobjects.

I create a lot of instances of this Class and these are succesfully pooled already. But I am wondering what to do with this options param like this one:
 

{
    type: "type",
    ...,
    bodies: [
        {
            type: "type"
            ...,
        },
        ...
    ],
    ...
}

Sometimes options param is hardcoded, sometimes algorithm gets it by net connection in arraybuffer to recreate {} & [];

What is worth pooling mechanism in javascript? For sure complex objects with a lot of properties and inner objects.

What about these little guys then? {} & []

Is it worth to pool empty plain objects and arrays? With releasing it to pool you would remove all properties in {} and setting length to 0 in array.

Share this post


Link to post
Share on other sites

That sounds like premature optimization. I would recommend ignoring pooling until you've determined that garbage collection has become a performance problem.

I recently implemented pooling for some large array buffers, which eliminated the GC spikes I was seeing, but I didn't bother pooling any smaller structures. If performance becomes a problem again, I will re-evaluate that decision.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.