[CDBI] C::DBI Memory usage

Perrin Harkins perrin at elem.com
Wed May 24 16:29:18 BST 2006

On Wed, 2006-05-24 at 15:55 +0100, Aaron Trevena wrote:
> But in that case the process would never need to assign that memory
> from fresh, it should be able to re-use the memory already allocated

Perl doesn't reclaim memory allocated for one variable for use in
another.  It keeps the memory there in case that variable gets as big
again.  You can reclaim the memory with explicit undefs.  However, if
you really never load large result sets or BLOBs, this is probably not
the source of your problem.

> I'm thinking the problem lies in a packaged scoped hash somewhere that
> is updated frequently and just keeps on grabbing more memory and not
> returning it. My suspicion is that it's in C::DBI somewhere.

If that's true, Devel::Size will help you find it.  Or try
Devel::Size::Report and look for anything over a certain size.

Also, check for other common problems in your code like slurping large
files or making copies of large variables.  None of that memory gets
reused for other variables unless you undef things.

- Perrin

More information about the ClassDBI mailing list