[Freeswitch-users] Memory leak

Tristan Mahé t.mahe at telemaque.fr
Mon Mar 14 17:39:55 MSK 2011


Hi,

I've never seen memleaks on luasql using the following code:

Feel free to use it and modify/improve ;)

----------------------------------------------- mysql.lua 
-----------------------------------------------

require 'luasql.mysql'

DB = {}
DB.__index = DB

function DB.create()
         local db = {}
         setmetatable(db,DB)
         db.env = assert( luasql.mysql() )
         db.con = assert( db.env:connect('DB','USER','PASSWORD','HOST') )
         return db
end

function DB:query(query)
         local q,r = self.con:execute(query)
         if q == nil then
                 return nil
         else
                 return q
         end
end

function DB:fetch(cur)
         if (cur ~= nil) then
                 return cur:fetch({},"a");
         else
                 return nil;
         end
end

function DB:close()
         self.con:close()
         self.env:close()
end

----------------------------------------------- /mysql.lua 
-----------------------------------------------

Exemple usage ( in a global do ... end block to ensure no data is global 
and everything is destroyed ):

local db = DB.create();
local r = db:query("SELECT * FROM test");
local f = db:fetch(r);
db:close();


Le 14/03/2011 15:28, Pete Kelly a écrit :
>
>
> On 14 March 2011 13:16, Steven Ayre <steveayre at gmail.com 
> <mailto:steveayre at gmail.com>> wrote:
>
>     If you use mod_lcr, we were getting a memory leak in that a few
>     weeks ago which is fixed in the latest git.
>
>
> No we are not. I am going to try strengthening up the code which 
> closes the DB connections. If that fails then I will compile and try 
> the ODBC driver.
>
>
>     -Steve
>
>
>     On 14 March 2011 09:30, Pete Kelly <pkelly at gmail.com
>     <mailto:pkelly at gmail.com>> wrote:
>
>         Hi
>
>         We are using Freeswitch (from git sources) in a production
>         environment to handle an IVR system using a simple set of
>         dialplans and lua scripts. OpenSIPS 1.6 and mysql are also
>         installed and running as part of the same IVR application.
>
>         However over time (approx 1 week) the memory usage of
>         Freeswitch increases, eventually creeping into swap space
>         forcing us to restart Freeswitch. The IVR handles approx 40
>         concurrent calls constantly, and we have instances of the IVR
>         running on a 32bit Etch and 64bit Lenny boxes - both exhibit
>         the same issue.
>
>         We have also tried the Sangoma freeswitch branch in case that
>         contained any fixes, however we see the same issues.
>
>         Can anybody advise if this is a known issue with Freeswitch?
>         Is it a memory leak or is it possible to limit the amount of
>         memory Freeswitch will use, forcing it to garbage collect when
>         it reaches the limit?
>
>         Any advice on where to look/debug next would be appreciated.
>
>         Thanks
>
>         Pete
>
>
>
>         _______________________________________________
>         FreeSWITCH-users mailing list
>         FreeSWITCH-users at lists.freeswitch.org
>         <mailto:FreeSWITCH-users at lists.freeswitch.org>
>         http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>         UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>         http://www.freeswitch.org
>
>
>
>     _______________________________________________
>     FreeSWITCH-users mailing list
>     FreeSWITCH-users at lists.freeswitch.org
>     <mailto:FreeSWITCH-users at lists.freeswitch.org>
>     http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>     UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>     http://www.freeswitch.org
>
>
>
> _______________________________________________
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20110314/c774ec25/attachment.html 


More information about the FreeSWITCH-users mailing list