2013-10-03

Allocate memory by Perl

仿效Java先allocate memory的作法可試著用Perl來做實驗, 作法如下:

#!/usr/bin/perl -w

for (0..10){
   my $buf = "A" x (1024 * 1024 * 100);
   print "Allocated " . length($buf) . " byte buffer\n";

}
print "Finished\n";
sleep(1000);