First of all, mysql_ php functions mysql_ no longer supported, and so you can use a more OOP approach like mysqli or PDO .
Since mysql_free_result()
free all memory associated with the result of the result identifier.
If you are extracting a lot of results, then yes, you can (and should) use this function to free up your mysql to save memory.
As for the rest of your question:
Will memory be freed when the method completes, or is it necessary to call mysql_free_result at the end of the method?
No, in case you do not use mysql_free_result , the memory will not be freed at the end of your method, but rather at the end of your script.
Hope this helps. Greetings.
source share