[CDBI] C::DBI Memory usage

Rhesa Rozendaal perl at rhesa.com
Wed May 24 13:47:00 BST 2006


Aaron Trevena wrote:
> Hi All,
> 
> I'm working on scheduling daemon in perl, it uses C::DBI to handle
> DB/Object Persistence, etc as you'd expect.
> 
> Unfortunately I'm having issues with the ammount of memory it uses
> after 24 hours of running.

I've seen the same issues, and see the same memory increases over time.
I'm using POE for my daemons, and haven't verified if cdbi is to blame for the 
increased memory usage.

> I've managed to replace the only global and long living objects and
> data structures with  array-based objects so I no longer have any
> global or package hashes in the main daemon class - unfortunately it
> uses several CDBI classes (no plugins) and I'm starting to think these
> are gobbling memory.

In my case, the only global object is POE's kernel and the initial session. 
All dispatching is done using objects.

> I'm assuming that CDBI objects are hash based, and over time the size
> of those hashes will grow but none of the objects are in scope for
> more than a few minutes and so shouldn't be using memory - are there
> any global's that could be grabbing memory over time?

I'd like to know too :)

> Also has anybody else encountered this problem, or succesfully used
> CDBI in a long-running ( i.e. over 48 hours ) program?

I haven't had big issues running them for longer than two days, but since I 
have several, I've needed to keep a close eye on them. They typically grow by 
200MB virt/res over a day or so (depending on workload of course).

I've fixed my problems by making my daemons restart themselves after 24 hours 
or after a given number of tasks performed. When either condition is met and 
the daemon is idle, I let it fall out of the main loop, and have it call 
exec($0, @args). It seems to do the trick.

Rhesa



More information about the ClassDBI mailing list