in reply to Re: Re: Re: Re: Re: Finding the size of a variable
in thread Finding the size of a variable

Oh, I dunno, it doesn't take that long. And unfortunately it's the only really effective way to see how much memory's currently in use, though even then there are some interesting bits to deal with.

Also, don't forget that Devel::Profiler is pure perl, and thus has a fair amount of overhead. Devel::Size is entirely in C, and a fair amount faster. I'd guess we'd see about a factor of 100 speedup over a perl version, but it might be upwards of 200 to 300 times faster for what it does, as well as immune to a lot of the problems you'd find doing this in perl. (It's not tripped up by tying or overloading, for example)

  • Comment on Re: Re: Re: Re: Re: Re: Finding the size of a variable

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: Re: Finding the size of a variable
by samtregar (Abbot) on Nov 11, 2002 at 21:21 UTC
    Gee, that sounds great! When can I use it? ;)

    I'll be very interested to see just how fast it can walk every data structure in use by a large system like Bricolage. My gut reaction is still "a long time" but you clearly would know better than I!

    -sam

      Well, try it now! :)

      If the walk of \%main:: is unmanageable now, getting CVs right won't help. OTOH, if it's fast now, it won't get a whole lot slower later...

        A few quick tests show Devel::Size::total_size(\%::main) on Bricolage taking around a half a second right after startup, on my PIII/600. As the app is used and the various memory caches start to fill up that time increases up to around 1 second per call.

        While that's certainly not bad for most uses, adding a 1 second overhead to every subroutine call would bring Bricolage (or any large Apache/mod_perl app) to a halt. Some actions require thousands of method calls, and most web browsers would time out before the response got back.

        However, you were right about one thing; it is a heck of a lot faster than Devel::Profiler!

        -sam