function MigrateExecutable::attemptMemoryReclaim

Same name in other branches
  1. 9 core/modules/migrate/src/MigrateExecutable.php \Drupal\migrate\MigrateExecutable::attemptMemoryReclaim()
  2. 8.9.x core/modules/migrate/src/MigrateExecutable.php \Drupal\migrate\MigrateExecutable::attemptMemoryReclaim()
  3. 11.x core/modules/migrate/src/MigrateExecutable.php \Drupal\migrate\MigrateExecutable::attemptMemoryReclaim()

Tries to reclaim memory.

Return value

int The memory usage after reclaim.

1 call to MigrateExecutable::attemptMemoryReclaim()
MigrateExecutable::memoryExceeded in core/modules/migrate/src/MigrateExecutable.php
Tests whether we've exceeded the desired memory threshold.
1 method overrides MigrateExecutable::attemptMemoryReclaim()
TestMigrateExecutable::attemptMemoryReclaim in core/modules/migrate/tests/src/Unit/TestMigrateExecutable.php
Tries to reclaim memory.

File

core/modules/migrate/src/MigrateExecutable.php, line 607

Class

MigrateExecutable
Defines a migrate executable class.

Namespace

Drupal\migrate

Code

protected function attemptMemoryReclaim() {
    // First, try resetting Drupal's static storage - this frequently releases
    // plenty of memory to continue.
    drupal_static_reset();
    // Entity storage can blow up with caches, so clear it out.
    \Drupal::service('entity.memory_cache')->deleteAll();
    // @todo Explore resetting the container.
    // Run garbage collector to further reduce memory.
    gc_collect_cycles();
    return memory_get_usage();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.