Mario F. Posted March 1, 2008 Share Posted March 1, 2008 Hello all, Despite instructions from the PHP manual I want to use mysql_free_result() and mysql_close() consistently across my scripts. It's a matter of programming culture I acquired from other programming languages and I find it hard to let go, even during my apprenticeship of PHP. What I would like to know however is if by explicitly freeing these two resources, I may be losing the edge on some internal advantage I'm not aware of like memory pooling (in place for many servers, I hear) or garbage collecting that would take care of freeing the resources at more convenient times. I apologize for the assumptions in my question. I just don't know PHP well enough yet not to make them. Quote Link to comment https://forums.phpfreaks.com/topic/93917-use-of-mysql_free_result-and-mysql_close/ Share on other sites More sharing options...
Barand Posted March 2, 2008 Share Posted March 2, 2008 PHP has page scope for all variables. If you open a connection to a DB at the begining of a script it is closed at the end for you. The only time you may want to close a connection is when you need to connect to more that one server in a page script. If your script has more than one result set then, yes, you may want to save memory by freeing the results, particularly if they are large. Quote Link to comment https://forums.phpfreaks.com/topic/93917-use-of-mysql_free_result-and-mysql_close/#findComment-481284 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.