1

Trying to use the Simple HTML Dom Parser in my application.

Placed the sample function of scraping_slashdot() into a controller.

include_once('includes/simple_html_dom.php');
$ret = $this->scraping_slashdot();
print_r($ret);

Get:

ErrorException [ Fatal Error ]: Allowed memory size of 134217728 bytes exhausted (tried to allocate 291337 bytes)

The thing is that when I do the exact same thing in a stand-alone file (not as a part of a Ko app), everything seems to work just fine.

Does anyone have any idea what it could be?

PS

Using Ko 3.2, haven't tried other versions, though I've used this class in 3.0 before just fine.

Serhiy
  • 2,505
  • 3
  • 33
  • 49
  • Are you trying to scrape one PAGE of slashdot, or the entirety of slashdot? One page should **not** suck up anywhere near 128megs of ram, while the entirety of slashdot most definitely will. – Marc B Oct 03 '11 at 20:43
  • haha, just one page... the issue is that it works just fine and quick as a stand alone, but when I include it in a Kohana Controller things go haywire... Maybe this is bad practice in general....? public function action_index() { include_once('includes/simple_html_dom.php');.... – Serhiy Oct 03 '11 at 22:20

1 Answers1

0

Your script is trying to allocate more memory then allowed. Try using a profiler (Xdebug) to see where does the leak come from or use workaround solution - ini_set('memory_limit', '-1') or set it directly in php.ini if you have access.

matino
  • 17,199
  • 8
  • 49
  • 58
  • Well then, this is a whole new level of development that I wasn't prepared for... I'll give it a try... I just hope I don't break PHP in the process... I can't do this kind of analysis via Kohana's profiler can i? – Serhiy Oct 03 '11 at 20:07
  • Nope but don't be afraid, Xdebug is easy to use and there are plenty of tutorials available :) – matino Oct 04 '11 at 07:08