Ton script a fait planter ma machine en remplissant lentement mais sûrement la RAM (et ma swap était déjà atteinte...). Donc j'ai cherché comment corriger et apparemment fgets dans une boucle infinie c'est une mauvaise idée : https://www.google.com/search?q=php+fgets+memory+leak
J'ai d'abord testé gc_enable et gc_collect_cycles disponibles depuis PHP 5.3 mais ma RAM continuait à se remplir à chaque exécution. J'ai finalement trouvé stream_select : "The streams listed in the read array will be watched to see if characters become available for reading"
Donc j'ai pu boucher la fuite avec
// Disable bufferingsystem("stty -icanon -echo min 0 time 0");// Stream arrays$in=[STDIN];$out=NULL;$oob=NULL;while(stream_select($in,$out,$oob,NULL)){if(fgetc(STDIN)!==false){TapTempo::tap();}}
# Ça fuit !
Posté par Faya . En réponse au journal Portage de TapTempo en PHP. Évalué à 10.
Ton script a fait planter ma machine en remplissant lentement mais sûrement la RAM (et ma swap était déjà atteinte...). Donc j'ai cherché comment corriger et apparemment fgets dans une boucle infinie c'est une mauvaise idée : https://www.google.com/search?q=php+fgets+memory+leak
J'ai d'abord testé gc_enable et gc_collect_cycles disponibles depuis PHP 5.3 mais ma RAM continuait à se remplir à chaque exécution. J'ai finalement trouvé stream_select : "The streams listed in the read array will be watched to see if characters become available for reading"
Donc j'ai pu boucher la fuite avec
L'appel system("stty -icanon") permet de désactiver le buffer de STDIN d'après https://www.mail-archive.com/php-general@lists.php.net/msg151195.html