develooper Front page | perl.perl5.porters | Postings from September 2000

Memory allocation in 5.6

Thread Next
From:
Marc D. Spencer
Date:
September 28, 2000 18:14
Subject:
Memory allocation in 5.6
Message ID:
v0422080cb5f99c3355cf@[192.168.0.4]
I'm totally at a loss;

Can someone explain the following:

This code:
-----
#!/usr/local/bin/perl

use bytes;

my $foo = 'x' x ($ARGV[0] * 1024000);

sleep $ARGV[1] if $ARGV[1];
print "Released.\n";
-----

Before:

marcs [~]> free
              total       used       free     shared    buffers     cached
Mem:        517120      71032     446088      17368      10552       9788
-/+ buffers/cache:      50692     466428
Swap:      1052216      55784     996432

During run: (with $ARGV[0] = 100)

marcs [~]> free
              total       used       free     shared    buffers     cached
Mem:        517120     272200     244920      18552      10688      10188
-/+ buffers/cache:     251324     265796
Swap:      1052216      55784     996432


seems to allocate twice the memory I ask it for. This wouldn't be a 
problem, except I'm manipulating images in scalars, so they can be 
large.


Any thoughts?


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About