To Free mysqli result or not
To Free mysqli result or not
am 12.11.2007 05:19:57 von mudgen
In php documentation there is this note about mysqli_free_result():
Note: You should always free your result with mysqli_free_result(),
when your result object is not needed anymore.
With the similar non-mysqli function there is this note:
mysql_free_result() only needs to be called if you are concerned about
how much memory is being used for queries that return large result
sets. All associated result memory is automatically freed at the end
of the script's execution.
I'm just wondering why you need to free the result when using mysqli
and not when you are using mysql_free_result().
Does mysqli not automatically free resources when the php script
execution finishes?
Re: To Free mysqli result or not
am 12.11.2007 15:44:02 von sai narasimha reddy
On Nov 12, 9:19 am, mudge wrote:
> In php documentation there is this note about mysqli_free_result():
>
> Note: You should always free your result with mysqli_free_result(),
> when your result object is not needed anymore.
>
> With the similar non-mysqli function there is this note:
>
> mysql_free_result() only needs to be called if you are concerned about
> how much memory is being used for queries that return large result
> sets. All associated result memory is automatically freed at the end
> of the script's execution.
>
> I'm just wondering why you need to free the result when using mysqli
> and not when you are using mysql_free_result().
>
> Does mysqli not automatically free resources when the php script
> execution finishes?
I think it does....when the execution of a page completes, all the
data members related to that page are freed.
Re: To Free mysqli result or not
am 12.11.2007 18:27:15 von colin.mckinnon
On 12 Nov, 14:44, sai narasimha reddy wrote:
> On Nov 12, 9:19 am, mudge wrote:
>
>
>
> > In php documentation there is this note about mysqli_free_result():
>
> > Note: You should always free your result with mysqli_free_result(),
> > when your result object is not needed anymore.
>
> > With the similar non-mysqli function there is this note:
>
> > mysql_free_result() only needs to be called if you are concerned about
> > how much memory is being used for queries that return large result
> > sets. All associated result memory is automatically freed at the end
> > of the script's execution.
>
> > I'm just wondering why you need to free the result when using mysqli
> > and not when you are using mysql_free_result().
>
> > Does mysqli not automatically free resources when the php script
> > execution finishes?
>
> I think it does....when the execution of a page completes, all the
> data members related to that page are freed.
It may behave differently with persistent connections - mysqli pushes
more functionality out into the binary lib.
Is it such a big problem to do as they suggest?
C.
Re: To Free mysqli result or not
am 13.11.2007 16:49:53 von mudgen
On Nov 12, 9:27 am, "C. (http://symcbean.blogspot.com/)"
wrote:
> On 12 Nov, 14:44, sai narasimha reddy wrote:
>
>
>
> > On Nov 12, 9:19 am, mudge wrote:
>
> > > In php documentation there is this note about mysqli_free_result():
>
> > > Note: You should always free your result with mysqli_free_result(),
> > > when your result object is not needed anymore.
>
> > > With the similar non-mysqli function there is this note:
>
> > > mysql_free_result() only needs to be called if you are concerned about
> > > how much memory is being used for queries that return large result
> > > sets. All associated result memory is automatically freed at the end
> > > of the script's execution.
>
> > > I'm just wondering why you need to free the result when using mysqli
> > > and not when you are using mysql_free_result().
>
> > > Does mysqli not automatically free resources when the php script
> > > execution finishes?
>
> > I think it does....when the execution of a page completes, all the
> > data members related to that page are freed.
>
> It may behave differently with persistent connections - mysqli pushes
> more functionality out into the binary lib.
>
> Is it such a big problem to do as they suggest?
>
> C.
No, it is a point of understanding. I wish to understand, not follow.
Re: To Free mysqli result or not
am 13.11.2007 18:20:46 von Jerry Stuckle
mudge wrote:
> On Nov 12, 9:27 am, "C. (http://symcbean.blogspot.com/)"
> wrote:
>> On 12 Nov, 14:44, sai narasimha reddy wrote:
>>
>>
>>
>>> On Nov 12, 9:19 am, mudge wrote:
>>>> In php documentation there is this note about mysqli_free_result():
>>>> Note: You should always free your result with mysqli_free_result(),
>>>> when your result object is not needed anymore.
>>>> With the similar non-mysqli function there is this note:
>>>> mysql_free_result() only needs to be called if you are concerned about
>>>> how much memory is being used for queries that return large result
>>>> sets. All associated result memory is automatically freed at the end
>>>> of the script's execution.
>>>> I'm just wondering why you need to free the result when using mysqli
>>>> and not when you are using mysql_free_result().
>>>> Does mysqli not automatically free resources when the php script
>>>> execution finishes?
>>> I think it does....when the execution of a page completes, all the
>>> data members related to that page are freed.
>> It may behave differently with persistent connections - mysqli pushes
>> more functionality out into the binary lib.
>>
>> Is it such a big problem to do as they suggest?
>>
>> C.
>
> No, it is a point of understanding. I wish to understand, not follow.
>
>
Actually, you should always call mysql_free_result() when through with
the result set. Although the garbage collector will free the result
when you leave the page, it does release MySQL resources sooner. And
you really shouldn't depend on the garbage collector - it's just bad
programming practice, IMHO.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: To Free mysqli result or not
am 13.11.2007 18:33:38 von Courtney
Jerry Stuckle wrote:
> mudge wrote:
>> On Nov 12, 9:27 am, "C. (http://symcbean.blogspot.com/)"
>> wrote:
>>> On 12 Nov, 14:44, sai narasimha reddy wrote:
>>>
>>>
>>>
>>>> On Nov 12, 9:19 am, mudge wrote:
>>>>> In php documentation there is this note about mysqli_free_result():
>>>>> Note: You should always free your result with mysqli_free_result(),
>>>>> when your result object is not needed anymore.
>>>>> With the similar non-mysqli function there is this note:
>>>>> mysql_free_result() only needs to be called if you are concerned about
>>>>> how much memory is being used for queries that return large result
>>>>> sets. All associated result memory is automatically freed at the end
>>>>> of the script's execution.
>>>>> I'm just wondering why you need to free the result when using mysqli
>>>>> and not when you are using mysql_free_result().
>>>>> Does mysqli not automatically free resources when the php script
>>>>> execution finishes?
>>>> I think it does....when the execution of a page completes, all the
>>>> data members related to that page are freed.
>>> It may behave differently with persistent connections - mysqli pushes
>>> more functionality out into the binary lib.
>>>
>>> Is it such a big problem to do as they suggest?
>>>
>>> C.
>>
>> No, it is a point of understanding. I wish to understand, not follow.
>>
>>
>
> Actually, you should always call mysql_free_result() when through with
> the result set. Although the garbage collector will free the result
> when you leave the page, it does release MySQL resources sooner. And
> you really shouldn't depend on the garbage collector - it's just bad
> programming practice, IMHO.
>
that is highly arguable: when php exits, its not necessarily php that
cleans it all up. on a *nix platform all the memory allocated to the
process including the code space is freed anyway.
Delaying program close to use PHP'S internal garbage collector may
simply be a duplication of effort, and it probably does not have one
anyway. Why reinvent the wheel? I'll bet its straight call to the OS
free() function anyway.
Re: To Free mysqli result or not
am 13.11.2007 20:37:27 von Jerry Stuckle
The Natural Philosopher wrote:
> Jerry Stuckle wrote:
>> mudge wrote:
>>> On Nov 12, 9:27 am, "C. (http://symcbean.blogspot.com/)"
>>> wrote:
>>>> On 12 Nov, 14:44, sai narasimha reddy wrote:
>>>>
>>>>
>>>>
>>>>> On Nov 12, 9:19 am, mudge wrote:
>>>>>> In php documentation there is this note about mysqli_free_result():
>>>>>> Note: You should always free your result with mysqli_free_result(),
>>>>>> when your result object is not needed anymore.
>>>>>> With the similar non-mysqli function there is this note:
>>>>>> mysql_free_result() only needs to be called if you are concerned
>>>>>> about
>>>>>> how much memory is being used for queries that return large result
>>>>>> sets. All associated result memory is automatically freed at the end
>>>>>> of the script's execution.
>>>>>> I'm just wondering why you need to free the result when using mysqli
>>>>>> and not when you are using mysql_free_result().
>>>>>> Does mysqli not automatically free resources when the php script
>>>>>> execution finishes?
>>>>> I think it does....when the execution of a page completes, all the
>>>>> data members related to that page are freed.
>>>> It may behave differently with persistent connections - mysqli pushes
>>>> more functionality out into the binary lib.
>>>>
>>>> Is it such a big problem to do as they suggest?
>>>>
>>>> C.
>>>
>>> No, it is a point of understanding. I wish to understand, not follow.
>>>
>>>
>>
>> Actually, you should always call mysql_free_result() when through with
>> the result set. Although the garbage collector will free the result
>> when you leave the page, it does release MySQL resources sooner. And
>> you really shouldn't depend on the garbage collector - it's just bad
>> programming practice, IMHO.
>>
>
> that is highly arguable: when php exits, its not necessarily php that
> cleans it all up. on a *nix platform all the memory allocated to the
> process including the code space is freed anyway.
>
> Delaying program close to use PHP'S internal garbage collector may
> simply be a duplication of effort, and it probably does not have one
> anyway. Why reinvent the wheel? I'll bet its straight call to the OS
> free() function anyway.
>
>
>
Except what's being released is not in PHP's memory space. It's in
MySQL's. And PHP's garbage collector must issue the mysql_free_result()
for it.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================