On Fri, 19 May 2000, David Larkin wrote:

> Can anyone help explain why PERL gives such a large memory
> footprint & advise how to get around it.
> 
> Running the simple script below, I get a footprint of 63 MB
> about 22 bytes per int.
> 
> The C program only 11748 K ... 4 bytes per int
> 
> 
> #!/usr/local/bin/perl
> for ( $i=0 ; $i< 3000000 ; $i++ )
> {
>         $X[$i]=int(1);
> }
> 
> 
> main()
> {
>         int x[3000000];
>         sleep(60);
> }
> 
> I guess I'm paying the price for PERL not being strongly typed,
> a feature I really like ( until now ;-) )
> 
> I require a large array of ints in a real application, just stripped
> problem down to bear bones for demo.
> 
> I'd be grateful for any advice

When you really need the C/C++ slimness use XS to glue C/C++ code for your
Perl code, don't just switch to C, which can be not development speed
wise.

A great XS tutorial (especially for simple things like your example):

http://perlmonth.com/columns/modules/modules.html?issue=6
http://perlmonth.com/columns/modules/modules.html?issue=7
http://perlmonth.com/columns/modules/modules.html?issue=8
http://perlmonth.com/columns/modules/modules.html?issue=9
http://perlmonth.com/columns/modules/modules.html?issue=10

Enjoy! And encourage Steven McDougall (the author) to write more of this
great stuff :)

_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide 
mailto:[EMAIL PROTECTED]   http://perl.org     http://stason.org/TULARC
http://singlesheaven.com http://perlmonth.com http://sourcegarden.org

Reply via email to