Git Product home page Git Product logo

Comments (7)

coopernurse avatar coopernurse commented on July 24, 2024

Hi there,

Keeping track of objects in the pool seems reasonable -- I'm not sure there's a huge downside. Can you think of one?

Seems like that would be fairly easy to implement. Do you have a fork of the code? If so, please take a pass at implementing this and issue a pull request to me.

thank you!

-- James

from node-pool.

Poetro avatar Poetro commented on July 24, 2024

The only downside is, if the application using the pool doesn't clean up after itselft, the objects in the pool may not get garbage collected, as there is still reference to them. So solving it is not quite trivial, as it can introduce memory leak as well as the pool filling in without "knowing" why.

from node-pool.

coopernurse avatar coopernurse commented on July 24, 2024

We could introduce a max checkout timeout to workaround this. It would work similarly to the idle timeout. if an element in the pool is checked out for more than the checkout timeout, we destroy it and remove it from the pool.

would that work?

from node-pool.

hoodoos avatar hoodoos commented on July 24, 2024

well, this problem is as old as ehmm.. as something really-really old.
don't you remember about
var conn = undefined;

try{
conn = pool.getConnection();
}
finally{
conn.release();
}

this max checkout is hacky solution which can posibly bring more pain then profit when some long running jobs will eventually get dropped because of it.

But maybe will work :)

from node-pool.

Poetro avatar Poetro commented on July 24, 2024

As I checked through the Object pool pattern recently as I'm writing a Node.js article, I realized that the destroy shouldn't even be a public property. Only the borrow / returnToPool should be public. Maybe it should even be renamed to those that are in the pattern description. Anyways I've already forked the module, and will commit my changes in the next couple of days.

from node-pool.

coopernurse avatar coopernurse commented on July 24, 2024

cool. looking forward to your commit.

from node-pool.

Poetro avatar Poetro commented on July 24, 2024

The destroy is now moved out of public scope.

from node-pool.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.