in reply to PerlApp (v.7) sharing perl58.dll

What I do now is to compile any .pl script as a .exe (everyone with perl58.dll). It works fine....but it uses a lot of memory.

Are you sure? (Ie. How are you measuring the memory usage?)

Generally, only one copy of any given .DLL is loaded into memory regardless of how many processes use it.

Although each process will display the memory used by the dll as a part of (one of the figures for) its memory consumption, as displayed in the task manager, second and subsequent copies will usually not consume extra from the total memory pool.

Eg. If I run a do nothing perl process: perl -e"<>", and check the memory usage on the Process Manager main screen, it lists it as using 5,592kb. If I then double click that entry and look at the "Performance" tab, in the "Physical Memory" box, it show the working set as 5.592k. But that is divided into 3 subsets of memory

  1. WS private: 2,200k ## This is exclusive to this process
  2. WS shareable: 3,392k ## The rest (2,200 + 3,392 = 5,592) can be shared with other processes.
  3. WS shared: 2,512k ## Of the 3,392k, 2,512 is currently being shared.

    In this case, as there are no other Perl processes running, that will be things like the C runtime DLL, code pages etc. that are a part of other compiled C applications.

And if you monitor the Physical Memory ("System Info" dialog), when you start that first copy of perl, you'll see that the Available memory drops by roughly 2.2 MB.

If you then start a second copy of perl in another session, whilst continuing to monitor the Performance tab of the first, you'll see the WS shared increase to 3,388k. This is because the second copy of Perl is now sharing the Perl5x.dll that was loaded by the first perl process. Now almost all the shareable memory is being shared.

So, whilst summing the main screen memory allocations for the two perl processes suggests they are using 5.592 * 2 = 11 MB, in fact between them they are only using 2.2 * 2 + 3.3 = 7.7MB. And of that 2.5 MB is being shared with other pre-existing processes.

And when starting a third, instead of 16.5MB, only 9.9MB is actually consumed.

This information doesn't mitigate the on-disk redundancy of each having it's own copy of perl5x.dll, but it might stop you worrying about memory consumed by them.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy