in reply to WHY copying does happen (fork)
"copy on write" only works at a granularity of a "page" of memory. A complex data structure is likely allocated "all over" the heap so even if you don't change any of it, you likely change other things on the pages that the parts of it ended up on. Add reference counting to that and you are very unlikely to keep much of any part of the heap shared (which is where Perl puts nearly everything). Allocate a huge string and don't change it and most of it (except some of each end) will stay shared.
- tye
|
---|