<font color="#666666"><font size="4"><font face="garamond,serif">Sua máquina não está aguentando 60 processos rodando simultaneamente, não sei se é isso que você quer, mas ao colocar seus &quot;filhos&quot; em background você está fazendo com que todos sejam executados simultaneamente. Só que seus filhos são como usuários concorrentes para o sistema operacional, então você deve pensar como se houvesse 60 pessoas trabalhando no seu servidor simultaneamente, pior, todas com processos rodando ao mesmo tempo... você consegue imaginar 60 firefox distintos utilizando a sua máquina ao mesmo tempo e acessando diferentes vídeos no you tube? pode até ser que sua máquina aguente, mesmo assim vai concordar comigo que toda máquina tem um limite.<br>
<br>Você tem consciência que seu script, do jeito que está, poderia ser escrito em bash, sem nenhum prejuízo. Ou não tem? É verdade que você pode fazer algo mais interessante/elegante com AnyEvent ou POE (são soluções que exigem um pouco mais de conhecimento de sintaxe e de programação do que o seu script transparece) pode ser um ótimo aprendizado, mas também pode ser um passo maior que a perna para o momento imediato... Eu não compreendi contudo se é um requisito rodar simultaneamente tantos scripts filhos quanto possíveis, nesse caso, mesmo usando fork, AnyEvent ou POE ainda haverá um limite, maior que usando system (bem maior), mas haverá. <br>
<br>Sou sempre a favor de aprender a solução mais elegante, mas entendo que algumas vezes precisamos de um hack e pode ser que o seu hack seja colocar um novo while na entrada do seu while atual do qual você só sai depois de verificar que a máquina tem recursos disponíveis e que seu o load está aceitável, lembrando de colocar um sleep 30 antes do final do while interno. Sim, tosco, mas pode lhe dar o tempo que precisa para estudar POE e AnyEvent sem ninguém resmungando ao seu pé-do-ouvido... <br>
<br clear="all"></font></font></font><font size="2"><span style="font-family: garamond,serif;">Atenciosamente, </span><br style="font-family: garamond,serif;"><br style="font-family: garamond,serif;"><span style="font-family: garamond,serif;">Leonardo Ruoso (CE1921JP)</span><br style="font-family: garamond,serif;">
<span style="font-family: garamond,serif;">
</span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><font size="1"><br style="font-family: garamond,serif;">
<a style="font-family: garamond,serif;" href="mailto:leonardo@ruoso.com" target="_blank">leonardo@ruoso.com</a><span style="font-family: garamond,serif;"> ·  (11) 3522-9612 · (85) 8787-0312</span><br style="font-family: garamond,serif;">
<a style="font-family: garamond,serif;" href="http://leonardo.ruoso.com/" target="_blank">http://leonardo.ruoso.com</a><span style="font-family: garamond,serif;"> · </span><a style="font-family: garamond,serif;" href="http://twitter.com/LeonardoRuoso" target="_blank">http://twitter.com/LeonardoRuoso</a><br style="font-family: garamond,serif;">
<span style="font-family: garamond,serif;"></span></font></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><font size="1"><span style="font-family: garamond,serif;"></span></font></font><font size="2"><font size="1"><span style="font-family: garamond,serif;"></span><br style="font-family: garamond,serif;">
<b style="font-family: garamond,serif;">Leonardo Ruoso </b><span style="font-family: garamond,serif;">· </span><b style="font-family: garamond,serif;"> </b><span style="font-family: garamond,serif;">Gerente de Projetos  · Analista de Sistemas</span><br style="font-family: garamond,serif;">
<span style="font-family: garamond,serif;">Comunicação Social/Jornalismo - UFC/2006 · Telecomunicações - ETFCE/1998</span><br style="font-family: garamond,serif;"><b style="font-family: garamond,serif;">Internet e inovação tecnológica deste 1996</b><br style="font-family: garamond,serif;">
<span style="font-family: garamond,serif;"></span></font></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><span style="font-family: garamond,serif;"><font size="1">. . . . . . </font></span></font><font size="2"><font size="1"><span style="font-family: garamond,serif;"></span></font></font>
 
 
<br>
<br><br><div class="gmail_quote">2011/1/20 Tom Mostard <span dir="ltr">&lt;<a href="mailto:capmostarda@gmail.com">capmostarda@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Olá, pessoal!<br><br>Estou tendo um problema de memória com scripts em Perl.<br>Alguém aí teve algum problema parecido?<br><br>Tenho um &quot;pequeno&quot; sistema que precisa executar vários scripts Perl em paralelo.<br>
Então existe um script Perl &quot;chefe&quot; que fica responsável por executar eles com parâmetros diferentes usando system().<br>
<br>O sistema acessa vários bancos de dados e a depender do banco, da tabela e do campo ele executa um módulo específico.<br>Uso o MySQL em outra máquina para não abusar da memória.<br>
<br>Script-chefe:<br><br>while ( my $i &lt; $execucoes ) # são execuções limitadas, mas por enquanto são 60<br>{<br>    system( &#39;./<a href="http://script.pl" target="_blank">script.pl</a> $parametro1 &gt; /dev/null &amp; &#39; );<br>


}<br><br>Dentro do script é carregado um módulo usando require assim:<br><br>require $ARGV[ 0 ].&quot;.pm&quot;;<br><br>Funciona tudo certo, se rodo 20, funciona tudo normal e eles ocupam 158 MB de memória.<br>Se rodo 40, eles ocupam 316 MB de memória além da memória usada pelo sistema.<br>


Me parece que cada script carregado usa 8 MB em média. (Isso é possível/normal?)<br>Quando uso 60, nem todos os scripts são executados.<br>Existe alguma maneira de executar um script otimizando o uso de memória ou<br>vou ter que reavaliar o código?<br>


Já revisei o código e eliminei arrays, variáveis de conexões com bancos desnecessárias.<br>Existe algo mais que eu possa fazer?<br><br>Abraços,<br><font color="#888888"><br>Tom<br>
</font><br>_______________________________________________<br>
Cascavel-pm mailing list<br>
<a href="mailto:Cascavel-pm@pm.org">Cascavel-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/cascavel-pm" target="_blank">http://mail.pm.org/mailman/listinfo/cascavel-pm</a><br></blockquote></div><br>