URL: https://linuxfr.org/forums/programmation-perl/posts/consommation-m%C3%A9moire-excessive Title: Consommation mémoire excessive Authors: Ontologia Date: 2005年11月30日T21:12:35+01:00 Tags: firefox Score: 0 Bonsoir, suite à [https://linuxfr.org/~golum/20068.html](https://linuxfr.org/~golum/20068.html) , j'ai écrit en perl le code correspondant. Je suis politiquement content puisqu'il marche, mais informatiquement dubitatif puisqu'il me bouffe plus de 40 mo au bout d'une heure d'utilisation. De bonne âmes pourraient-elles m'expliquer pourquoi (pour apprendre aux lecteurs ignorants) et proposer des solutions ? Merci :) Voici le code : #!/usr/bin/perl use WWW::Mechanize; use strict; use diagnostics; use warnings; my @url_list = £spaces£ £/spaces£( £spaces£ £/spaces£'[http://www.google.fr/search?num=100&hl=fr&client=fir(...)](http://www.google.fr/search?num=100&hl=fr&client=firefox-a&rls=org.mozilla%3Afr%3Aofficial&q=droite&btnG=Rechercher&meta=',) £spaces£ £/spaces£'[http://www.google.fr/search?num=100&hl=fr&client=fir(...)](http://www.google.fr/search?num=100&hl=fr&client=firefox-a&rls=org.mozilla%3Afr%3Aofficial&q=sarkozy&btnG=Rechercher&meta=',) £spaces£ £/spaces£'[http://www.google.fr/search?num=100&hl=fr&client=fir(...)](http://www.google.fr/search?num=100&hl=fr&client=firefox-a&rls=org.mozilla%3Afr%3Aofficial&q=chirac&btnG=Rechercher&meta=',) £spaces£ £/spaces£'[http://www.google.fr/search?num=100&hl=fr&client=fir(...)](http://www.google.fr/search?num=100&hl=fr&client=firefox-a&rls=org.mozilla%3Afr%3Aofficial&q=syndicats&btnG=Rechercher&meta=',) £spaces£ £/spaces£'[http://www.google.fr/search?num=100&hl=fr&client=fir(...)](http://www.google.fr/search?num=100&hl=fr&client=firefox-a&rls=org.mozilla%3Afr%3Aofficial&q=politique&btnG=Rechercher&meta=',) £spaces£ £/spaces£'[http://www.google.fr/search?num=100&hl=fr&client=fir(...)](http://www.google.fr/search?num=100&hl=fr&client=firefox-a&rls=org.mozilla%3Afr%3Aofficial&q=parti&btnG=Rechercher&meta=',) £spaces£ £/spaces£'[http://www.google.fr/search?num=100&hl=fr&client=fir(...)](http://www.google.fr/search?num=100&hl=fr&client=firefox-a&rls=org.mozilla%3Afr%3Aofficial&q=socialiste&btnG=Rechercher&meta=') £spaces£ £/spaces£); my $mech = WWW::Mechanize->new( autocheck => 1 ); for (my $i=0 ; $i< 512 ; $i++) { foreach my $url_google (@url_list) { £spaces£ £/spaces£$mech->get( $url_google ); £spaces£ £/spaces£sleep (rand(32)); £spaces£ £/spaces£my $htmltext = $mech->content; £spaces£ £/spaces£if ( $htmltext =~ /www\.u\-m\-p\.org\/site\/soutien_projet_2007/ ) £spaces£ £/spaces£{ £spaces£ £/spaces£my @txt = grep (/u\-m\-p\.org/,split(/\s|href=/,$htmltext)); £spaces£ £/spaces£foreach my $t (@txt){ £spaces£ £/spaces£if ($t =~ /soutien_projet_2007/ ) { # On l'a trouvé !! £spaces£ £/spaces£my $good_url = '[http://www.google.fr'.$t;](http://www.google.fr'.$t;) £spaces£ £/spaces£print $good_url,"\n"; £spaces£ £/spaces£$mech->get($good_url); £spaces£ £/spaces£if ($mech->content =~ /Mouvement\sPopulaire/) { # on est bien tombé sur la bonne page £spaces£ £/spaces£print '1 Hit effectué',"\n"; £spaces£ £/spaces£} £spaces£ £/spaces£} £spaces£ £/spaces£} £spaces£ £/spaces£} } }