Why this function uses a lot of memory?
问题 I'm trying to unpack binary vector of 140 Million bits into list. I'm checking the memory usage of this function, but it looks weird. the memory usage rises to 35GB (GB and not MB). how can I reduce the memory usage? sub bin2list { # This sub translates a binary vector to a list of "1","0" my $vector = shift; my @unpacked = split //, (unpack "B*", $vector ); return @unpacked; } 回答1: Scalars contain a lot of information. $ perl -MDevel::Peek -e'Dump("0")' SV = PV(0x42a8330) at 0x42c57b8 REFCNT