I'm using SimplePie with PHP 5.3 (with gc enabled) to parse my RSS feeds. This works well and without problems when doing something like the following:
$simplePie = new SimplePie();
$simplePie->set_feed_url($rssURL);
$simplePie->enable_cache(false);
$simplePie->set_max_checked_feeds(10);
$simplePie->set_item_limit(0);
$simplePie->init();
$simplePie->handle_content_type();
foreach ($simplePie->get_items() as $key => $item) {
$item->get_date("Y-m-d H:i:s");
$item->get_id();
$item->get_title();
$item->get_content();
$item->get_description();
$item->get_category();
}
Memory debugging over 100 iterations (with different RSS feeds):
But when using $item->get_permalink()
, my memory debugging looks like this over 100 iterations (with different RSS feeds).
Code to produce problem:
foreach ($simplePie->get_items() as $key => $item) {
$item->get_date("Y-m-d H:i:s");
$item->get_id();
$item->get_title();
$item->get_permalink(); //This creates a memory leak
$item->get_content();
$item->get_description();
$item->get_category();
}
Things I've tried:
- Using
get_link
instead ofget_permalink
- Using
__destroy
as mentioned here (even though it should be fixed for 5.3)
Current debugging process:
I seem to have traced the problem down to SimplePie_Item::get_permalink
-> SimplePie_Item::get_link
-> SimplePie_Item::get_links
-> SimplePie_Item::sanitize
-> SimplePie::sanitize
-> SimplePie_Sanitize::sanitize
-> SimplePie_Registry::call
-> SimplePie_IRI::absolutize
as of now.
What can I do to fix this?