Is it necessary to close the mongoose connection?
-
I've read lots of tutorials but they never seem to call mongoose.connection.close(). When should this be called? Is it not necessary? How often in my application should I be creating a new connection?
-
Answer:
When you are developing application and making a connection to mongodb database, you use single instance of connection for all database operation in an entire application, so it doesn't matter whether you close a connection or not. But for an instance you are running a test cases for a same application each time you open a new connection and perform a operation for each test cases, in this scenario if you don't close a connection at the end of each test cases, the connections will get piled up and you will run short of memory. So, you decide where it is compulsory to close connection and where not, all based on situation. I hope, I gave satisfactory explanation for your query.
Soni Pandey at Quora Visit the source
Related Q & A:
- Is it necessary to close connections in urllib2?Best solution by Stack Overflow
- How to perform a query in mongoose?Best solution by Quora
- Why the autorelease pool is necessary in main.m?Best solution by Stack Overflow
- What education is necessary to become a genetic engineer?Best solution by study.com
- Illl can sumbody tell me how we can get a wireless connection for the internet connection?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.