Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

PerlApp binary size

by RicardoPortilho (Novice)
on Jan 05, 2006 at 16:40 UTC ( #521263=perlquestion: print w/replies, xml ) Need Help??

RicardoPortilho has asked for the wisdom of the Perl Monks concerning the following question:

Hello, all.
I'm using perlapp (ActiveState PDK) to create a Windows binary, but my 16k script becomes a 2 MB binary, and uses 16MB RAM!!! I think it's because of the modules I use, here are they:
use Sys::Hostname; use Win32::IPConfig; use DBI; use Win32::MachineInfo; use Win32::DriveInfo; use Win32API::File; use Win32::TieRegistry(Delimiter=>"#", ArrayValues=>0); use Mail::SendEasy;
What are the guidelines I should use to minimize the memory usage? I'm already using stricts, warnings, and setting the variables to undef when I don need them anymore.

Thanks in advance.

jdporter added code tags

Replies are listed 'Best First'.
Re: PerlApp binary size
by monkey_boy (Priest) on Jan 05, 2006 at 17:18 UTC
    I suspect this is where the large binary comes from...

    The PerlApp utility converts a Perl program into a standalone application. This utility combines a Perl program, all of the required Perl modules and a modified Perl interpreter into one binary unit.
    from this doc


    This is not a Signature...
Re: PerlApp binary size
by Tanktalus (Canon) on Jan 05, 2006 at 17:18 UTC

    I'm trying to figure out exactly what Windows you're targetting where 2MB of disk space or 16MB of RAM is significant.

    By its nature, perl uses more memory for the same work than, say, C. This is to allow the dynamic use where strings and numbers end up being the same thing as references, tied variables, etc. Each variable will have certain overhead to allow this. It's not the end of the world.

    Then you use a bunch of Win32 modules - these will load additional Win32 DLLs into your perl programspace. But they aren't actually using additional memory - that same memory is being mapped into every process that uses those DLLs. And that would include the program that runs as your desktop.

    Personally, I only care about memory when AIX tells me I've run out. And then I just tell AIX to shut up by resetting my ulimit ;-)

Re: PerlApp binary size
by pKai (Priest) on Jan 05, 2006 at 21:25 UTC

    I'm using perlapp (and even more perlsvc) from AS PDK all the time at work.

    A simple "Hello world!" (standalone program) will compile to short under 800K, since the exe will contain the perl interpreter in the form of the perl58.dll.

    You can add (use) alot of pure perl modules in your program and the size of the resulting exe will not increase a lot (of about the size of the pm(s) these modules consist of).

    The real increase comes when you include (a lot) of modules using compiled C code, i.e. attaching a module dll to your app.

    You will quite easily break the 2MB with those (modules of the Win32 namespace are likely candidates to add most of the volume to your exe.)

Re: PerlApp binary size
by blazar (Canon) on Jan 05, 2006 at 17:04 UTC

    I'm not familiar with PerlApp, so I am not aware of any guideline to minimize memory usage. But it sounds quite reasonable that the size of the executable is due to the modules you're using.

    What I wanted to add is that strict (and warnings) per se has nothing to do with memory usage, AFAIK. But since you're already "forced" to use lexical variables, if you scope them suitably, then you should not need to explicitly "set them to undef when you don't need them anymore".

Re: PerlApp binary size
by spiritway (Vicar) on Jan 06, 2006 at 05:36 UTC

    This is something like needing the runtime module for Visual Basic programs. If you make your .exe program fully self-contained, it will run on computers that don't have Perl installed, and won't require addional .dll's. The problem is that the self-contained .exe must have all this functionality in it, which makes it large.

    It is possible to select options in perlapp that will create much smaller .exe binaries. You can do this, if you know your .exe is going to be run on machines that have Perl installed, and that have perl*.dll. When using perlapp, click on the "Size" tab and check the boxes for "Make dependent executable", and "Exclude perl58.dll from executable".

    If you're running several .exe programs, it may pay to have Perl and the .dll installed, and creating smaller .exe files that can use them. If it's only one or two programs, or if you don't have the option of installing Perl, then you are pretty well stuck with a large .exe and the memory use.

Re: PerlApp binary size
by Anonymous Monk on Jan 05, 2006 at 21:31 UTC
    It has been 1 or 2 years ... the Perl2exe product ('Pro' version?) has a feature that let you build the .exe file in different sizes. One version builds smaller .exe without the .dll files. But you must install and have .dll available at runtime. (This might be useful for group of .exe?) Just a thought. Perhaps, the perlapp product has a similar feature. Bill

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://521263]
Approved by Joost
Front-paged by Thilosophy
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2021-12-07 13:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (33 votes). Check out past polls.

    Notices?