in reply to Should Devel::Size work on tied arrays?

Kung-Fu is a good description of the nature of what Devel::Size has to do in order to inspect perl data internals. I agree that you identified a limitation not obvious from the module's documentation.

On top of my wish list for things to be able to get the size of would be closures.

I wonder if we can expect a tool like Devel::Size to become much more complete, given how perl's intestines are not only eclectic to boot but also a moving target.

Another approach to track memory consumption might be called for. Perhaps something along the lines of the black-box attitude of Benchmark, only measuring space rather than time.

Any Takers?

  • Comment on Re: Should Devel::Size work on tied arrays?

Replies are listed 'Best First'.
Re^2: Should Devel::Size work on tied arrays?
by salva (Canon) on Feb 01, 2006 at 16:24 UTC
      maybe, something like Memchmark?

      Almost, but not quite, since Memchmark watches behaviour of code while the point here is to examine static data.

      A helpful technique might be to duplicate data over and over in order to increase the scale (though that is not trivial, think of shared hash keys and deeply nested references) while tracking overall memory consumption, and then doing some math.

Re^2: Should Devel::Size work on tied arrays?
by Elian (Parson) on Feb 01, 2006 at 20:30 UTC
    Hrm. Devel::Size should handle closures properly -- I remember adding in code last summer to walk pads attached to code references, and some testing showed that it looked to work, but I may well have missed something in there. I'll go look and see what's going on.

    And yeah, Devel::Size does some... interesting things to get the total size of data structures. There's lots of evil knowledge of the size of things. For the most part that knowledge is version-independent, but not all of it. (Arguably there should be a Devel::Size-ish thing bundled as part of a perl distribution because it is so potentially version-dependent, but that's throwing more work on the core internals group, and they've enough to do as it is)

      Devel::Size should handle closures properly

      Uh-oh. As coderefs are mentioned in the bugs section it didn't occur to me to file a bug report. Devel::Size appears to report unreasonably constant sizes of closures, and I get "Attempt to free unreferenced scalar" warnings also. Please /msg me if you need more details.