Google Curl Using all memory in php 5.3.8

I used this to translate the main text of the site into different languages. It did a great job until I upgraded to PHP 5.3.8. It completely destroyed my server using all the memory. What am I doing wrong? I am sure to say that I will get a lot of comments :)

try { $gt = new Gtranslate; $gt->setRequestType('curl'); $SQL = "SELECT * FROM PAGE_CONTENT WHERE live_page = '1'"; $result = mysql_query($SQL); while ($row = mysql_fetch_array($result)) { $page_id_sub = $row["page_id"]; $page_title = $row["page_title"]; $page_permalink = $row["page_permalink"]; if (empty($mylang)) { echo "<a href='/$permalink/$page_permalink.html'>$page_title</a> |"; } else { $page_trans = $gt->$mylang("$page_title"); echo "<a href='/$permalink/$page_permalink.html'>$page_trans</a> |"; } } } catch (GTranslateException $ge) { echo $ge->getMessage(); } 
+6
source share
1 answer

I would debug this to check which process is stuck.

 <?php echo "\n start: " . memory_get_usage() . "\n"; try{ $gt = new Gtranslate; $gt->setRequestType('curl'); echo "\n after class: " . memory_get_usage() . "\n"; $SQL = "SELECT * FROM PAGE_CONTENT WHERE live_page = '1'"; $result = mysql_query( $SQL ); echo "\n after query: " . memory_get_usage() . "\n"; while( $row = mysql_fetch_array( $result ) ) { $page_id_sub = $row["page_id"]; $page_title = $row["page_title"]; $page_permalink = $row["page_permalink"]; if(empty($mylang)){ echo "<a href='/$permalink/$page_permalink.html'>$page_title</a> |"; } else { $page_trans = $gt->$mylang("$page_title"); echo "<a href='/$permalink/$page_permalink.html'>$page_trans</a> |"; } } echo "\n after while: " . memory_get_usage() . "\n"; } catch (GTranslateException $ge){ echo $ge->getMessage(); } echo "\n end: " . memory_get_usage() . "\n"; 
+6
source

Source: https://habr.com/ru/post/900099/


All Articles