#!/usr/bin/perl -w use strict; use warnings; sub MemoryEaterFunc { my $A = ''; vec($A, 20000000, 8) = 0; # Create a large string $A .= $_[0]; # Add to it. Do something. # Evaluate the last statement, # and that is the return value of the sub! even if # you don't write return $A; it still returns it. # If you want the function to not return the big string, # then put 'return 0;' at the end of the sub. } $a = ; MemoryEaterFunc(2); # Eats memory and doesn't release it $a = ;