Jump to content

Pooling. What is worth it, what is not.


hashi
 Share

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.

Link to comment
Share on other sites

  • 4 weeks later...

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...