do u consciously close your db connection every time you're done with it?
what happens if i just continue on to another page without closing the connection... is this bad practice?
closing db connections
Moderator: General Moderators
-
microthick
- Forum Regular
- Posts: 543
- Joined: Wed Sep 24, 2003 2:15 pm
- Location: Vancouver, BC
-
fractalvibes
- Forum Contributor
- Posts: 335
- Joined: Thu Sep 26, 2002 6:14 pm
- Location: Waco, Texas
Always good practice to close all connections, dispose of objects,etc.
after you are done with them. Esp. with anything where licensing gives you N number of concurrent instances and no more!
Some languages might have good garbage collection whilst others do not.
Run a tight ship in that respect and you'll be better off.
FV
after you are done with them. Esp. with anything where licensing gives you N number of concurrent instances and no more!
Some languages might have good garbage collection whilst others do not.
Run a tight ship in that respect and you'll be better off.
FV
I'd recommend to close it too.Sami wrote:I always close it. Though I did use an open source script where it wasn't closed in a hundred or so places but it didn't make for any security leak or MySQL errors. Just bad practice. I recommend doing so, especially if you're going to release the application to the world.
Quoting php.net: "...all resources that were in use for this resource are made free by the garbage collector. For this reason, it is rarely ever necessary to free the memory manually by using some free_result function."
With my limited knowledge of english and how the Zend engine/garbage collector works, 'rarely' is not enough for me.