public function XmlSitemapGenerator::setMemoryLimit in XML sitemap 8
Same name and namespace in other branches
- 2.x src/XmlSitemapGenerator.php \Drupal\xmlsitemap\XmlSitemapGenerator::setMemoryLimit()
Calculate the optimal memory level for sitemap generation.
Parameters
int $new_limit: An optional PHP memory limit in bytes. If not provided, the value of getOptimalMemoryLimit() will be used.
Overrides XmlSitemapGeneratorInterface::setMemoryLimit
1 call to XmlSitemapGenerator::setMemoryLimit()
- XmlSitemapGenerator::regenerateBefore in src/
XmlSitemapGenerator.php - Perform operations before rebuilding the sitemap.
File
- src/
XmlSitemapGenerator.php, line 238
Class
- XmlSitemapGenerator
- XmlSitemap generator service class.
Namespace
Drupal\xmlsitemapCode
public function setMemoryLimit($new_limit = NULL) {
$current_limit = @ini_get('memory_limit');
if ($current_limit && $current_limit != -1) {
if (!is_null($new_limit)) {
$new_limit = $this
->getOptimalMemoryLimit();
}
if (Bytes::toInt($current_limit) < $new_limit) {
return @ini_set('memory_limit', $new_limit);
}
}
}