[Freeswitch-users] memory leak

Benedikt Fraunhofer fraunhofer.lists.freeswitch-001 at traced.net
Wed Sep 2 07:19:14 PDT 2009


Hello Brian,

2009/9/2 Brian West <brian at freeswitch.org>:
> What are you doing in these lua scripts?  Because there are a few things you
> can do in the lua script itself that will cause you to leak like crazy due
> to improper use.
> /b

the setup is the same as in http://jira.freeswitch.org/browse/MODSOFIA-22

one is

-----

local reason = session:getVariable("originate_disposition");

session:setAutoHangup(false);


if(reason) then
    if(reason == "NO_ANSWER") then
 -- nothing
    end
    if(reason == "USER_BUSY") then
        -- nothing
    end
end

freeswitch.consoleLog(...

------
anotherone is
----
local sess = "nil";
if(argv[1]) then
    sess=argv[1];
end
freeswitch.consoleLog(...
api = freeswitch.API();
local res = api:execute("sched_api" ...
freeswitch.consoleLog(...

----

and the scheduled script does
---
function log(msg)
    freeswitch.consoleLog("notice", "c2c-hangup-timeout.lua: " .. msg .. "\n");
end


local sess = argv[1];
if(sess)
then
    freeswitch.consoleLog("INFO", "hangup-timeout.lua for uuid " ..
sess .. "\n");

    api = freeswitch.API();
    local stillValid = api:execute("uuid_getvar", sess .. "
Dummy-DoesChannelExists");
    if(stillValid:sub(1,4) == "-ERR")
    then
        log("session uuid " .. sess .. " disappeared (nothing bad)");
    else
        -- this is important!!! Otherwise the aleg get's just hung up!
        api:execute("uuid_media", sess);
        api:execute("uuid_transfer", sess .. " -both timeout");
    end
else -- /if(sess)
    log("called with nil session?");
end -- /if(sess)

---

i don't have to do some kind of "free()" on all local variables, do i?

Thx.
  Beni.




More information about the FreeSWITCH-users mailing list