Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Memory leak on CLI commands with module installed #29

Open
Tomasz-Silpion opened this issue Dec 5, 2017 · 1 comment
Open

Memory leak on CLI commands with module installed #29

Tomasz-Silpion opened this issue Dec 5, 2017 · 1 comment

Comments

@Tomasz-Silpion
Copy link

There seems to be some kind of hole that causes lot of memory leaking on php bin/magento CLI usage on custom scripts or even Mirasvit_ElasticSearch usage having the Mirasvit_Profiler installed on the store.

Wasted some hours of the team for debugging custom products importer, downgrading the store and plugins. We've finally figured out, that without any warning the reason of 20MB being added to memory through each loop element comes from the module-profiler 👎 :(

@george-vlahakis
Copy link

george-vlahakis commented Nov 24, 2019

It is actually not a memory "leak" precisely. The profiler naturally stores information during operations. However I do agree CLI commands should not trigger the profiler...

I too wasted 3 days on this going down to PHP source build and MySql drivers check... pfff 🤬

Can be changed here I suppose to force CLI to $canEnable = false:

$_SERVER['MAGE_PROFILER_STAT'] = new \Magento\Framework\Profiler\Driver\Standard\Stat();

$canEnable = defined('BP');

if (PHP_SAPI == 'cli') {
    $canEnable = false;
    // global $argv;
    // if (isset($argv[1]) && substr($argv[1], 0, strlen('setup')) == 'setup') {
    //     $canEnable = false;
    // }
}

if ($canEnable) {
    \Magento\Framework\Profiler::applyConfig([
        'drivers' => [
            [
                'output' => 'Mirasvit\Profiler\Model\Driver\Output\Html',
                'stat'   => $_SERVER['MAGE_PROFILER_STAT'],
            ],
        ],
    ], 'BP', false);
}

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Mirasvit_Profiler',
    __DIR__ . '/src/Profiler'
);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants