Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes)
After upgrading to the latest version 7.0.1 I have been getting a memory allocation issue.
Symfony\Component\ErrorHandler\Error\FatalError
Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes)
Here is the same code that is being used.
$sitemap_count = 0;
$sitemap = resolve('sitemap');
Model::active()
->chunk(50000, function ( $objects ) use ( $sitemap, $sitemap_count ) {
$sitemap_count++;
$sitemap_filename = 'sitemap' . ($sitemap_count > 1 ? '-' . $sitemap_count : '');
foreach ($objects as $object) {
$sitemap->add($object->url);
}
$sitemap->store('xml', $sitemap_filename, $this->sitemap_path);
$sitemap->model->resetItems();
$sitemap->addSitemap(url('sitemaps/' . $sitemap_filename . '.xml.gz'), now());
});
Memory constantly growing even though I am using the resetItems()
method.
- sitemap (670MB)
- sitemap-2 (743MB)
- sitemap-3 (817MB)
- sitemap-4 (890MB)
- sitemap-5 (964MB)
- sitemap-6 (1037MB)
- sitemap-7 (1111MB)
- sitemap-8 (1184MB)
- sitemap-9 (1166MB)
- sitemap-9 (Boom!!!)
Here is a screenshot from the error log