You are here

protected function MigrationBase::memoryExceeded in Migrate 6.2

Same name and namespace in other branches
  1. 7.2 includes/base.inc \MigrationBase::memoryExceeded()

Test whether we've exceeded the desired memory threshold. If so, output a message.

Return value

boolean TRUE if the threshold is exceeded, FALSE if not.

1 call to MigrationBase::memoryExceeded()
Migration::checkStatus in includes/migration.inc
Standard top-of-loop stuff, common between rollback and import - check for exceptional conditions, and display feedback.

File

includes/base.inc, line 947
Defines the base class for migration processes.

Class

MigrationBase
The base class for all objects representing distinct steps in a migration process. Most commonly these will be Migration objects which actually import data from a source into a Drupal destination, but by deriving classes directly from MigrationBase…

Code

protected function memoryExceeded() {
  $usage = memory_get_usage();
  $pct_memory = $usage / $this->memoryLimit;
  if ($pct_memory > $this->memoryThreshold) {
    self::displayMessage(t('Memory usage is !usage (!pct% of limit !limit), starting new batch', array(
      '!pct' => round($pct_memory * 100),
      '!usage' => format_size(memory_get_usage()),
      '!limit' => format_size($this->memoryLimit),
    )), 'warning');
    return TRUE;
  }
  else {
    return FALSE;
  }
}