Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Latest Strawberries: addresses reported by "p", Devel::Peek, etc.

by dave_the_m (Monsignor)
on Oct 30, 2025 at 23:25 UTC ( [id://11166627]=note: print w/replies, xml ) Need Help??


in reply to Latest Strawberries: addresses reported by "p", Devel::Peek, etc.

You are seeing Copy-on-Write in action. In 5.32, the 's' x 32 expression is constant-folded at compile time, creating a hidden SV containing the 32-byte string. At run time this buffer is copied to $s. In 5.42, the copy is deferred: both $s and the hidden SV share the same PV buffer. When something happens to $s which looks like its buffer is going to be modified, then at that point the buffer is finally copied. pack 'p' is a wild-enough operation that perl assumes the worst, so does the copy before returning the (new) PC address.

The larger addresses are nothing to do with perl; they are just what the underlying OS and malloc() library supply.

Dave.

  • Comment on Re: Latest Strawberries: addresses reported by "p", Devel::Peek, etc.

Replies are listed 'Best First'.
Re^2: Latest Strawberries: addresses reported by "p", Devel::Peek, etc.
by Anonymous Monk on Oct 31, 2025 at 10:08 UTC

    Thanks for explanation. Looks like "'COW + p' leak by design now" to me, but maybe the case is too artificial for real life. I think pack has "You are responsible..." warning already.

    use strict; use Devel::Peek; $Devel::Peek::pv_limit = 3; # useless for UTF8 use warnings; use feature 'say'; say $^V; sub mem { say qx( tasklist /nh /fi "PID eq $$" ) =~ m[(\S+ K)$] } mem(); { my $r = \ join '', 'a' .. 'z'; $$r x= 1e7; my $s = $$r; my $p = pack 'p', $s; } mem(); { my $r = \ join '', 'a' .. 'z'; $$r x= 1e7; my $s = $$r; my $p = pack 'p', $s; } mem(); __END__ v5.32.1 7,836 K 7,888 K 7,888 K v5.42.0 8,036 K 261,972 K 515,880 K

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11166627]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2026-02-18 16:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.