use Devel::Size qw(size total_size); sub foo { print "in foo\n"; } print "size foo: ",size(*foo),"\n"; print "total_size foo: ",total_size(*foo),"\n"; print "size bar: ",size(*bar),"\n"; print "total_size bar: ",total_size(*bar),"\n"; print "difference: ",size(*foo) - size(*bar),"\n"; __END__ size foo: 7034 total_size foo: 7034 size bar: 7186 total_size bar: 7186 difference: -152