[html-formfu] New Element::Date leaks memory?

Carl Franks fireartist at gmail.com
Fri Aug 24 15:45:35 GMT 2007


On 24/08/07, Tobias Kremer <list at funkreich.de> wrote:
> By the way: I just realized that incorporating FormFu makes Catalyst grow from
> 11 megs to 27 megs - that's a pretty huge memory usage IMHO. Can you confirm
> this?

For me, a basic Cat app running under the built-in server uses 14MB.

If I make Controller/Root.pm a sub-class of
Catalyst::Controller::HTML::FormFu, it becomes 22MB.
Then after hitting the homepage (outputting a completely empty form),
it becomes 24 MB.

So the total increase is 10MB.

If I comment out the line in Catalyst/Controller/HTML/FormFu.pm which
loads HTML::FormFu::Preload - then memory usage is only 15 MB.
And after a page view, increases to 17MB.

So... to summarize:
The most basic FormFu packages take up about 1MB of RAM.
The backend / render packages take up about another 2MB.
All of the elements / deflators / filters / constraints / inflators /
validators (and their dependencies) take up another 7MB.

A general solution could be to separate some of the filters,
constraints, etc. out to their own packages - that way you wouldn't
need to install what you won't use, and they won't be auto-loaded and
using up RAM.

There are only a few prereqs which could be considered optional -
Encode, DateTime, Email::Valid and HTML::Scrubber.
However, a perl process with these loaded is only about 3.5 MB larger
than a perl process with no modules at all loaded. - Not a great
saving.

A better solution might be to remove the "use HTML::FormFu::Preload"
line from Catalyst/Controller/HTML/FormFu.pm - then hit all of your
pages, so you know everything's loaded - and then check the memory
usage.

If it's significantly lower than before, then it's because a lot of
elements, etc. were being loaded that were never being used.
At that point, you'd have to weigh up whether you want the slight
performance hit of each new fastcgi process having to require() any
element it hasn't seen before - in return for the reduced RAM usage.

A final, but less desirable option would be to remove from your @INC
paths, any elements, constraints, etc which you know you won't use.

Carl



More information about the HTML-FormFu mailing list