On Mon, Sep 03, 2012 at 05:43:06AM -0400, Tim_Bunce via RT wrote:
Show quoted text> Mon Sep 03 05:43:05 2012: Request 79366 was acted upon.
> Transaction: Ticket created by TIMB
> Queue: Devel-Size
> Subject: size(sub {}) returns >8KB because it includes CvSTASH
> Broken in: (no value)
> Severity: (no value)
> Owner: Nobody
> Requestors: TIMB@cpan.org
> Status: new
> Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=79366 >
Yes, I think that it's a bug to recurse into CvSTASH().
In Perl_sv_clear() there is this:
case SVt_PVCV:
case SVt_PVFM:
cv_undef(MUTABLE_CV(sv));
/* If we're in a stash, we don't own a reference to it.
* However it does have a back reference to us, which needs to
* be cleared. */
if ((stash = CvSTASH(sv)))
sv_del_backref(MUTABLE_SV(stash), sv);
goto freescalar;
The CV doesn't own a reference to its stash. Therefore, it's not causing the
memory used by the stash to remain allocated. So that memory shouldn't be
accounted to the CV.
I think that Devel::Size ought to be aiming to be reporting something like
"how much memory is owned by the thing I was passed?" or
"how much memory would be freed if the thing I was passed were freed?" and
not "what is reachable from here?"
The problem is that the first two don't are both useful, and they aren't
always the same. For example, shared resources that are jointly owned by two
or more objects, such as shared string table entries.
But in this case its unambiguous.
Nicholas Clark