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

Hello all.

I create small script, which download several files with 4-8 Mb size from ftp with Net::FTP module.

Running on Debian 7.5 it takes only 5 Mb memory. But on Windows 7 memory usage is 230 Mb! I try to test on another Windows 7 machine with latest version of perl and ftp-module, but it takes the same memory.

I want to know why this happens and how to reduce the memory usage?

use warnings; use feature 'say'; use Net::FTP; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); my $ftp = Net::FTP->new('mirror.ufs.ac.za', Debug => 0, Passive => 1, +BlockSize => 104857600); $ftp->login('anonymouse', 'anon@nymo.use'); $ftp->binary; $ftp->cwd('/applications/filezilla/FileZilla_Client/3.9.0.6/'); foreach my $line ($ftp->dir()) { eval { if ($line =~ /^(?<dir>[\-ld])(?<permission>([\-r][\-w][\-xs]){ +3})\s+(?<filecode>\d+)\s+(?<owner>\w+)\s+(?<group>\w+)\s+(?<size>\d+) +\s+(?<timestamp>((?<month>\w{3})\s+(?<day>\d{1,2})\s+(?<hour>\d{1,2}) +:(?<minute>\d{2}))|((?<month2>\w{3})\s+(?<day2>\d{1,2})\s+(?<year>\d{ +4})))\s+(?<name>.+)$/) { my %remote_file_info = %+; if ($remote_file_info{dir} eq '-') { if ($ftp->get($remote_file_info{name}, 'files/' . $rem +ote_file_info{name})) { } else { die($ftp->message); } } } }; if ($@) { say($@); } } $ftp->quit; undef($ftp);

Replies are listed 'Best First'.
Re: Net::FTP memory usage in Windows
by BrowserUk (Patriarch) on May 25, 2016 at 14:07 UTC

    Two further comments:

    1. If I run your code unmodified, I get the private working set as 115MB (with the Virtual Size: 210MB).

      But if I modify BlockSize => 104857600 (100MB) to BlockSize => 1024**2 (1MB), then the PWS falls to 14MB (VS:108MB).

      So basically, 92% of the PWS size is down to the 100MB buffer you've requested.

    2. However you are measuring this on Linux, it's lying to you. (Or ignoring your request for a 100MB buffer.)

      You can't have a process with a 100MB buffer only occupying 15MB.

    You need to ensure that you're comparing apples with apples; which you evidently aren't yet.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    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". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Net::FTP memory usage in Windows
by BrowserUk (Patriarch) on May 24, 2016 at 18:20 UTC
    on Windows 7 memory usage is 230 Mb!

    How are you measuring the memory usage?


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    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". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
      In task manager.

        What does the heading of the memory column in the task manager read?


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        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". I knew I was on the right track :)
        In the absence of evidence, opinion is indistinguishable from prejudice.