Comments (7)
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.
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.
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.
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.
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.
cool. looking forward to your commit.
from node-pool.
The destroy is now moved out of public scope.
from node-pool.
Related Issues (20)
- Im not getting any performance using a pool connection vs reusing one connection
- waitingClientsCount function has disappeared HOT 1
- resource release not getting called HOT 2
- NPM installation faliure HOT 2
- Add param to factory
- Feature: add pool.use method. HOT 1
- Borrowed resources never go higher than 1 HOT 2
- Share pool between servers in a cluster HOT 3
- How to work maxWaitingClients? HOT 1
- Add destroy timeout to prevent pool.clear from hanging when destroy promise never resolves HOT 4
- testOnReturn = no-op?
- What does happen if I don't release the resource and close the node? HOT 2
- Resource not currently part of this pool HOT 1
- `ready` method from Pool is missing from the TS definitions (v3.8.2)
- .use does not handle synchronous work functions
- Consistently occuring `ResourceRequest timed out` Error HOT 1
- TimeoutError: ResourceRequest timed out HOT 2
- Suggested Feature: borrowTimeoutMillis HOT 2
- Pool does not maintain the minimum HOT 1
- Suggestion on softEvictConnections
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-pool.