I wrote a few programs, do not know why the memory has been increased from 20M has been added to xxG.

The number of processes to keep about 100.

Please help me, thank you!

My environment:

CentOS7

Perl 5.20.3

#!/usr/bin/perl -w # fork.pl $SIG{INT}=\&INT_EXIT; use IO::Socket::SSL; use Mojo::Asset; use Mojo::Asset::File; use Mojo::Asset::Memory; use Mojo::Base; use Mojo::Content; use Mojo::Content::MultiPart; use Mojo::Content::Single; use Mojo::Cookie; use Mojo::Cookie::Request; use Mojo::EventEmitter; use Mojo::Exception; use Mojo::IOLoop; use Mojo::IOLoop::Client; use Mojo::IOLoop::Delay; use Mojo::IOLoop::Server; use Mojo::IOLoop::Stream; use Mojo::JSON; use Mojo::Loader; use Mojo::Message; use Mojo::Parameters; use Mojo::Path; use Mojo::Reactor; use Mojo::Reactor::Poll; use Mojo::Server; use Mojo::Server::Daemon; use Mojo::Transaction; use Mojo::Transaction::HTTP; use Mojo::Transaction::WebSocket; use Mojo::URL; use Mojo::UserAgent; use Mojo::UserAgent::CookieJar; use Mojo::UserAgent::Proxy; use Mojo::UserAgent::Server; use Mojo::UserAgent::Transactor; use Mojo::Util; use Mojo::WebSocket; use File::Find; use Parallel::ForkManager; $|=1; my %ID; my $dir='/home/root/Perl/zhubo/AccountID'; my $fork; my %Header; my $ua; &Config; &Header; &Mojo_UA; my $pm=new Parallel::ForkManager($fork); sub Config{ open(F,"conf.json") or die; my @conf=<F>; close F; chomp @conf; my $json=join('',@conf); $json_conf=Mojo::JSON::decode_json($json); $fork=$json_conf->{'fork'}; } sub Header{ my @header=<headers/*>; foreach my $H(@header){ next unless($H=~m/\.header$/); my $hn; $hn=$1 if($H=~m/.*\/(.*?)\.header$/); open(H,$H) or die; while(my $h=<H>){ chomp $h; my @H=split('=>',$h); $Header{$hn}{'header'}{$H[0]}=$H[1]; } close H; } } sub Mojo_UA{ $ua=Mojo::UserAgent->new; $ua=$ua->connect_timeout($json_conf->{'connect_timeout'}); $ua=$ua->inactivity_timeout($json_conf->{'inactivity_timeout'}); $ua=$ua->max_redirects($json_conf->{'max_redirects'}); } while(1){ File::Find::find(\&wanted,$dir); } $pm->wait_all_children; sub wanted { if(-f $File::Find::name){ if($File::Find::name=~m/\.next$/){ if(exists $ID{$_}){ my $o=$File::Find::name; $o=~s/\.next$/.bak/; unlink($o); $o=~s/\.bak$//; unlink($o); delete $ID{$_}; } } if($File::Find::name=~m/\.bak$/){ my $gh=$_; my $e=$gh; $gh=~s/\.bak$//; my $f=$_; $f=~s/\.bak$//; unless(exists $ID{$f}){ my $fuck=&AccountID($f); if($fuck ne 'NULL'){ $ID{$f}=1; my $pid=$pm->start and next; system("/home/root/Perl/zhubo/ZhuBo.pl $f"); delete $ID{$f}; rename($e,$gh); $pm->finish; } undef $fuck; } } else{ my $r=$File::Find::name.'.bak'; rename($File::Find::name,$r); unless(exists $ID{$_}){ my $fuck=&AccountID($_); if($fuck ne 'NULL'){ $ID{$_}=1; my $pid=$pm->start and next; system("/home/root/Perl/zhubo/ZhuBo.pl $_"); my $e=$r; $e=~s/\.bak$//; delete $ID{$_}; rename($r,$e); $pm->finish; } undef $fuck; } } } } sub AccountID{ my $accountId=shift; my $url='https://taobaolive.taobao.com/room/index.htm?userId='.$acco +untId; my $res; while(1){ my $eval=eval{ $res=$ua->get($url=>{%{$Header{'item_list'}{'header'}}})->result +; }; last if($eval); } if($res->is_success){ my $body=$res->body; if($body=~m/var liveDetail \= (.*?) \|\| \{\}\;/s){ my $liveDetail=$1; unless($liveDetail=~m/\}$/){ undef $res; undef $body; undef $liveDetail; return 'NULL'; } my $json_hash=Mojo::JSON::decode_json($liveDetail); if(exists $json_hash->{'liveId'}){ if($json_hash->{'liveId'} ne '0'){ my $liveId=$json_hash->{'liveId'}; undef $json_hash; undef $res; undef $body; undef $liveDetail; return $liveId; } else{ undef $json_hash; undef $res; undef $body; undef $liveDetail; return 'NULL'; } } else{ undef $json_hash; undef $res; undef $body; undef $liveDetail; return 'NULL'; } } else{ &AccountID($accountId); } } else{ &AccountID($accountId); } } sub INT_EXIT{ exit; }

In reply to Memory has been increasing, unable to release memory. by Perl_Love

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.