TrueMember Posted May 6, 2020 Share Posted May 6, 2020 Hi again, I did a simple request and i get right response from curl_exec($ch); but when i call the static method str_get_html my result is always the same. Quote Fatal error: Allowed memory size of 536870912 bytes exhausted I tried increase the memory memory_limit=2048M but the result is the same. Proof of memory limit: Memory Limit I also tried ->clear(); unset(); but doesn't work. I'm using the following library: kub-at/php-simple-html-dom-parser My code: $url = "https://www.php.net"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, []); $this->callback = HtmlDomParser::str_get_html(curl_exec($ch)); .... Any tips? I can use regular expression, but will be my last choice. Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/310712-fatal-error-allowed-memory-size-of-bytes-exhausted/ Share on other sites More sharing options...
requinix Posted May 6, 2020 Share Posted May 6, 2020 If you tried increasing the memory limit and the memory limit didn't increase then you didn't increase the memory limit. You did you edit the correct file? Restart PHP or your web server? Quote Link to comment https://forums.phpfreaks.com/topic/310712-fatal-error-allowed-memory-size-of-bytes-exhausted/#findComment-1577614 Share on other sites More sharing options...
Barand Posted May 7, 2020 Share Posted May 7, 2020 A common cause of memory exhaustion is infinite recursion. Are you sure about that callback? Quote Link to comment https://forums.phpfreaks.com/topic/310712-fatal-error-allowed-memory-size-of-bytes-exhausted/#findComment-1577631 Share on other sites More sharing options...
TrueMember Posted May 7, 2020 Author Share Posted May 7, 2020 9 hours ago, requinix said: If you tried increasing the memory limit and the memory limit didn't increase then you didn't increase the memory limit. You did you edit the correct file? Restart PHP or your web server? Yes, you can see the proof in the first post. 59 minutes ago, Barand said: A common cause of memory exhaustion is infinite recursion. Are you sure about that callback? I don't understand why. To try i added the code to controller and it happens again.. $url = "https://www.php.net"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, []); $response = curl_exec($ch); $dom = HtmlDomParser::str_get_html($response); echo '<pre>'; print_r($dom->find(".title")); echo '</pre>'; $dom->clear(); unset($dom); die(); Quote Link to comment https://forums.phpfreaks.com/topic/310712-fatal-error-allowed-memory-size-of-bytes-exhausted/#findComment-1577632 Share on other sites More sharing options...
TrueMember Posted May 7, 2020 Author Share Posted May 7, 2020 Any tips? I Quote Link to comment https://forums.phpfreaks.com/topic/310712-fatal-error-allowed-memory-size-of-bytes-exhausted/#findComment-1577643 Share on other sites More sharing options...
kicken Posted May 7, 2020 Share Posted May 7, 2020 The problem is that you are trying to print_r the result. The object created by that library is large and recursive so you can't just easily dump it. 1 Quote Link to comment https://forums.phpfreaks.com/topic/310712-fatal-error-allowed-memory-size-of-bytes-exhausted/#findComment-1577645 Share on other sites More sharing options...
TrueMember Posted May 7, 2020 Author Share Posted May 7, 2020 37 minutes ago, kicken said: The problem is that you are trying to print_r the result. The object created by that library is large and recursive so you can't just easily dump it. Thank you, that's it!😀 Quote Link to comment https://forums.phpfreaks.com/topic/310712-fatal-error-allowed-memory-size-of-bytes-exhausted/#findComment-1577652 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.