in reply to Re: WHY copying does happen (fork)
in thread WHY copying does happen (fork)
The refcount isn't changed, even though a variable is read from a forked process. And why should it? I see no need for that.use Devel::Peek; my $x = 3; Dump $x; fork; Dump $x; __END__ SV = IV(0x90e54bc) at 0x90ca648 REFCNT = 1 FLAGS = (PADBUSY,PADMY,IOK,pIOK) IV = 3 SV = IV(0x90e54bc) at 0x90ca648 REFCNT = 1 FLAGS = (PADBUSY,PADMY,IOK,pIOK) IV = 3 SV = IV(0x90e54bc) at 0x90ca648 REFCNT = 1 FLAGS = (PADBUSY,PADMY,IOK,pIOK) IV = 3
The matter is different when variables go out of scope: then their refcount is reduced, thus possibly modifying it before deallocating.
Update It's probably this you meant:
use Devel::Peek; my $x = 3; Dump $x; my $y = \$x; Dump $x; __END__ SV = IV(0x97634bc) at 0x9748648 REFCNT = 1 FLAGS = (PADBUSY,PADMY,IOK,pIOK) IV = 3 SV = IV(0x97634bc) at 0x9748648 REFCNT = 2 FLAGS = (PADBUSY,PADMY,IOK,pIOK) IV = 3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: WHY copying does happen (fork)
by Corion (Patriarch) on May 05, 2008 at 17:22 UTC |