This is what I get on my Windows XP SP3 system using ActiveState Perl 5.14.2. Task Manager showed Commit charge: 778M/3958M when I ran the following script:
#!/usr/bin/env perl use strict; use warnings; use Devel::Size qw(total_size); my $unit = 1024 * 1024; my $topj = (8 * $unit) - 1; my @data; for my $i (0 .. 31) { print "$i: "; my @row; $#row = $topj; for my $j (0 .. $topj) { $row[$j] = 0.25; } push @data, \@row; printf "%.0f\n", total_size(\@data)/$unit; }
Output:
C: \ temp> yy
0: 224
1: 448
2: 672
3: 896
4: 1120
5: 1344
6: 1568
7: 1792
Out of memory!
eight:
On the other hand, the following C program improves:
#include <stdlib.h> #include <stdio.h> #define ROWSIZE 8*1024*1024 int main(void) { int n = 1; while (calloc(ROWSIZE, sizeof(double))) { printf("%d: success!\n", n); n += 1; } return 0; }
Output:
1: success!
2: success!
3: success!
...
26: success!
27: success!
for the same mark of 1.7 GB.
source share