public function XmlSitemapGenerator::getOptimalMemoryLimit in XML sitemap 2.x
Same name and namespace in other branches
- 8 src/XmlSitemapGenerator.php \Drupal\xmlsitemap\XmlSitemapGenerator::getOptimalMemoryLimit()
Calculate the optimal PHP memory limit for sitemap generation.
This function just makes a guess. It does not take into account the currently loaded modules.
Return value
int Optimal memory limit.
Overrides XmlSitemapGeneratorInterface::getOptimalMemoryLimit
1 call to XmlSitemapGenerator::getOptimalMemoryLimit()
- XmlSitemapGenerator::setMemoryLimit in src/
XmlSitemapGenerator.php - Calculate the optimal memory level for sitemap generation.
File
- src/
XmlSitemapGenerator.php, line 217
Class
- XmlSitemapGenerator
- XmlSitemap generator service class.
Namespace
Drupal\xmlsitemapCode
public function getOptimalMemoryLimit() {
$optimal_limit =& drupal_static(__FUNCTION__);
if (!isset($optimal_limit)) {
// Set the base memory amount from the provided core constant.
$optimal_limit = Bytes::toInt(DRUPAL_MINIMUM_PHP_MEMORY_LIMIT);
// Add memory based on the chunk size.
$optimal_limit += xmlsitemap_get_chunk_size() * 500;
// Add memory for storing the url aliases.
if ($this->config
->get('prefetch_aliases')) {
$aliases = $this->connection
->query("SELECT COUNT(id) FROM {path_alias}")
->fetchField();
$optimal_limit += $aliases * 250;
}
}
return $optimal_limit;
}