Hi,
Docs says 
It is not necessary to free a reply to use it again in a new redis_cmd function. When ndb_redis module closes, all pending replies are freed automatically..

Question is when is ndb_redis module closed, if there are no active calls it should be closed, shouldn't it?

I am using variable in each Lua function, even if they are global they should be wiped off after call is finished?

I will see how to work collectgarbage("collect") as explained by Michael Hajek in another email.

Thanks guys.





On Tue, Apr 16, 2024 at 8:27 PM Yuriy G via sr-users <sr-users@lists.kamailio.org> wrote:
You don't using redis_free
And also your lua bars seems to be globals...

On Tue, Apr 16, 2024, 10:44 Michal Hajek via sr-users <sr-users@lists.kamailio.org> wrote:
Hi,

you can try calling collectgarbage("collect") in Lua code.

Michal

út 16. 4. 2024 v 9:25 odesílatel Muhammad Danish Moosa via sr-users <sr-users@lists.kamailio.org> napsal:
Hi,

I am using kamailio with KEMI Lua.  The script has some medium level complexity as it stores some information from the invite in redis cache during the call and uses that information during the call transfers (REFER and Invite triggered by REFER).

Lua script itself creates/sets some variables, and sends/retrieves information during the flow for example
KSR.ndb_redis.redis_cmd("srvN", "SET coreCI-" .. varCI .. " " .. KSR.pv.getw("$ci") .. " EX 3600", "r");
KSR.ndb_redis.redis_cmd("srvN", "GET refvar-" .. cid, "r");
reft=KSR.pv.getw("$redis(r=>value)");

I made a test call and disconnected, what I am observing is that even if the call is finished the used memory is slightly increased.

before:
<       real_used: 844240
<       real_used: 844088
<       real_used: 844088
<       real_used: 844088
<       real_used: 844088
<       real_used: 844088
<       real_used: 844088
<       real_used: 844088
after:
>       real_used: 846080
>       real_used: 845864
>       real_used: 846584
>       real_used: 846304
>       real_used: 846200
>       real_used: 846120
>       real_used: 845248
>       real_used: 846168


My assumption is after finishing the call, memory used by variables and redis ops is released and should be back to original values but its not happening. In production this issue is causing some problems as I have to restart the kamailio process after every 3-4 weeks so that it starts breathing with more available memory.

Initially I thought its Kamailio version issue as in my last posts in this forum people advised me to upgrade to the latest kamailio version (original one was 5.4.0) but the same issue is happening on 5.7.0.

Can someone explain how to debug/troubleshoot this situation . I have a parallel lab environment, I do not see anything interesting in syslogs.


--
Muhammad Danish Moosa

" The core of mans' spirit comes from new experiences. "___ Christopher McCandless
__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-leave@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-leave@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-leave@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:


--
Muhammad Danish Moosa

" The core of mans' spirit comes from new experiences. "___ Christopher McCandless