in reply to Perl object memory overhead
There's no difference, since an allocated hash is already set up for being blessed.
push @l,{} for 1..3e7; # allocate 3 mill. anon hashes system "ps -o vsz= -p $$"; # get memory usage of process $_ = bless $_ for @l; # bless each hash into 'main' system "ps -o vsz= -p $$"; # again get memory usage __END__ 2650968 2650968
which shows: making an anonymous hash into an object means blessing it into a namespace. That operation signifies no overhead as far as memory is concerned, since the namespace bits are already allocated in the first place.
update: added comments
update: AnomalousMonk correctly noted that 3e7 for 3 millions is wrong by an order of magnitude. Who else noticed? ;)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Perl object memory overhead
by LanX (Saint) on Feb 10, 2021 at 23:54 UTC | |
by shmem (Chancellor) on Feb 12, 2021 at 00:53 UTC |