[Kamailio-Users] Freeing sqlops results

Daniel-Constantin Mierla miconda at gmail.com
Tue Feb 23 23:24:09 CET 2010


Hello,

On 02/22/2010 02:03 PM, Henning Westerholt wrote:
> On Monday 22 February 2010, Alex Balashov wrote:
>    
>> Should sql_result_free() always be called, no matter what the
>> circumstance, in order to discharge memory allocated to query result
>> sets and/or metadata?
>>
>> Or is it not necessary in certain situations, for example when script is
>> broken via 'exit', i.e.
>>
>>      sql_query("db", "SELECT ...", "res");
>>      if(! $dbr(res=>rows)) {
>>          # Is it necessary to call sql_result_free() here?
>>          exit;
>>      }
>>
>> Are results implicitly freed at the end of route script execution
>> anyway?  Are they tied to transaction persistence in any way?
>>      
> Hi Alex,
>
> my understanding of the module is that you need to call sql_result_free() afer
> every successful execution of sql_query(). The sql_query structure is not
> bound to any transactional behaviour or script routing logic. Daniel, please
> correct me when i'm wrong here.
>    

for sake of free memory you could call the free result every time. It is 
harmless if there was an error during the query.

For config simplicity, you can omit it, the previous result is freed 
before the next query.

Cheers,
Daniel
> Old results are freed when the module is destroyed as a cleanup, during an
> error of query execution and before a new query is started. But as every
> single invocation of sql_query could fail, i'd not recommend it to optimize
> the free operation away.
>
> Henning
>
> _______________________________________________
> Kamailio (OpenSER) - Users mailing list
> Users at lists.kamailio.org
> http://lists.kamailio.org/cgi-bin/mailman/listinfo/users
> http://lists.openser-project.org/cgi-bin/mailman/listinfo/users
>
>    

-- 
Daniel-Constantin Mierla
SIP Server Professional Solutions
* http://www.asipto.com/





More information about the sr-users mailing list