xmlsitemap_node_get_timestamps() maintains a static list of timestamps for every node it has seen in the current request:

  static $timestamps = array();

  if (!isset($timestamps[$node->nid])) {
...

When creating thousands of nodes in a process (say, hypothetically;), when migrating), that can add up. Using drupal_static() for this static cache at least presents the opportunity to recover the memory. The Migrate module does this when it senses memory_limit is drawing near, and generally recovers plenty to continue as long as no hooks are using local statics like this.

CommentFileSizeAuthor
#2 xmlsitemap-memory_leak-2065559-2.patch702 bytesmikeryan
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Category: bug » feature

Far from a bug. It'll depend on speed tests.

mikeryan’s picture

Status: Active » Needs review
FileSize
702 bytes

I personally would not consider a memory leak "far from a bug". Anyway, the patch is attached.

I've completed the massive migration run where this was killing me, it will be a bit before I have to do a rerun and have a chance to get some hard numbers using drupal_static. I can say that when I was running my migrations in chunks of 10000 nodes, I was hitting my 512M memory_limit somewhere around the 9000 point, but after disabling xmlsitemap I was able to do batches of 100000 without approaching it.

Dave Reid’s picture

Version: 7.x-2.0-rc2 » 7.x-2.x-dev
Status: Needs review » Fixed

This made sense to me. Committed #2 to 7.x-2.x.
http://drupalcode.org/project/xmlsitemap.git/commit/bbce7d6

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.