Greetings,
I'm trying to clean a SQL result using "sql_result_free()" but i'm not having success.
Can you please verify if i'm doing anything wrong here?
This is my code :
xerr("Pre clean [0] = Iterator 0 = $xavp(Cli_PICKER_Default_Search_Result[0]=>Code)"); sql_result_free("Cli_PICKER_Default_Search_Result"); xerr("Pos clean [0] = Iterator 0 = $xavp(Cli_PICKER_Default_Search_Result[0]=>Code)");
The result is the following :
ERROR: <script>:Pre clean [0] = Iterator 0 = 111111111111 ERROR: <script>:Pos clean [0] = Iterator 0 = 111111111111
Am i using sql_result_free correctly or doing something wrong?
Best Regards,
Hello,
I guess you are using sql_xquery? The sql_free_result will only free a native sql result in script, not the xavp.
Cheers,
Henning
-- Henning Westerholt – https://skalatan.de/blog/ Kamailio services – https://gilawa.comhttps://gilawa.com/
From: sr-users sr-users-bounces@lists.kamailio.org On Behalf Of Duarte Rocha Sent: Wednesday, June 24, 2020 5:59 PM To: Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org Subject: [SR-Users] Sql_result_free() not cleaning properly
Greetings,
I'm trying to clean a SQL result using "sql_result_free()" but i'm not having success.
Can you please verify if i'm doing anything wrong here?
This is my code :
xerr("Pre clean [0] = Iterator 0 = $xavp(Cli_PICKER_Default_Search_Result[0]=>Code)"); sql_result_free("Cli_PICKER_Default_Search_Result"); xerr("Pos clean [0] = Iterator 0 = $xavp(Cli_PICKER_Default_Search_Result[0]=>Code)");
The result is the following :
ERROR: <script>:Pre clean [0] = Iterator 0 = 111111111111 ERROR: <script>:Pos clean [0] = Iterator 0 = 111111111111
Am i using sql_result_free correctly or doing something wrong?
Best Regards,
On 6/29/20 4:27 PM, Henning Westerholt wrote:
I guess you are using sql_xquery? The sql_free_result will only free a native sql result in script, not the xavp.
But the XAVP goes out of scope once the transaction to which it pertains expires, right? And accordingly should be freed?
(This also leads one to wonder: if the same XAVP name is referenced in a subsequent sql_xquery() call in the course of processing the same message, will it free and re-allocate memory for a new PV, perhaps contributing to unnecessary fragmentation? Or will it simply reuse the SHM block for the previously allocated PV?)
-- Alex
Yes, $xavp(s) are bound to the transaction, like the $avp.
About the memory fragmentation - the memory manager should re-use fitting memory blocks, but this depends on the overall traffic to the server. In general, if you use a recent kamailio version, we activated the memory defragmentation some time ago. This should reduce the number of fragements. You can check with the shm stats. On old servers you can activate with a core parameter.
Cheers,
Henning
Hello,
On 29.06.20 22:30, Alex Balashov wrote:
On 6/29/20 4:27 PM, Henning Westerholt wrote:
I guess you are using sql_xquery? The sql_free_result will only free a native sql result in script, not the xavp.
But the XAVP goes out of scope once the transaction to which it pertains expires, right? And accordingly should be freed?
(This also leads one to wonder: if the same XAVP name is referenced in a subsequent sql_xquery() call in the course of processing the same message, will it free and re-allocate memory for a new PV, perhaps contributing to unnecessary fragmentation? Or will it simply reuse the SHM block for the previously allocated PV?)
The xavps are destroyed automatically only at the end of transaction (or end of processing the message, when the transaction is not created), so if you do the sql_xquery() many times for the same message, then it adds to the list of xavps (i.e., after the second xquery, you have xavps with values from the 2nd and 1st xquery). If you want to clean it up in the config, just assign $null to xavps.
Cheers, Daniel