Skip Menu |

This queue is for tickets about the Devel-Size CPAN distribution.

Report information
The Basics
Id: 79366
Status: open
Priority: 0/
Queue: Devel-Size

People
Owner: Nobody in particular
Requestors: TIMB [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: size(sub {}) returns >8KB because it includes CvSTASH
Subject: Re: [rt.cpan.org #79366] size(sub {}) returns >8KB because it includes CvSTASH
Date: Mon, 3 Sep 2012 11:19:36 +0100
To: Tim_Bunce via RT <bug-Devel-Size [...] rt.cpan.org>
From: Nicholas Clark <nick [...] ccl4.org>
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