/** * Test that application reinitialization produces no memory leaks */ public function testAppReinitializationNoMemoryLeak() { $this->markTestSkipped('Test fails at Travis. Skipped in scope of MAGETWO-48538'); $this->_deallocateUnusedMemory(); $actualMemoryUsage = $this->_helper->getRealMemoryUsage(); for ($i = 0; $i < self::APP_REINITIALIZATION_LOOPS; $i++) { \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(); $this->_deallocateUnusedMemory(); } $actualMemoryUsage = $this->_helper->getRealMemoryUsage() - $actualMemoryUsage; $this->assertLessThanOrEqual($this->_getAllowedMemoryUsage(), $actualMemoryUsage, sprintf("Application reinitialization causes the memory leak of %u bytes per %u iterations.", $actualMemoryUsage, self::APP_REINITIALIZATION_LOOPS)); }
/** * Test that application reinitialization produces no memory leaks */ public function testAppReinitializationNoMemoryLeak() { if (extension_loaded('xdebug')) { $this->markTestSkipped('Xdebug extension may significantly affect memory consumption of a process.'); } $this->_deallocateUnusedMemory(); $actualMemoryUsage = $this->_helper->getRealMemoryUsage(); for ($i = 0; $i < self::APP_REINITIALIZATION_LOOPS; $i++) { \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(); $this->_deallocateUnusedMemory(); } $actualMemoryUsage = $this->_helper->getRealMemoryUsage() - $actualMemoryUsage; $this->assertLessThanOrEqual($this->_getAllowedMemoryUsage(), $actualMemoryUsage, sprintf("Application reinitialization causes the memory leak of %u bytes per %u iterations.", $actualMemoryUsage, self::APP_REINITIALIZATION_LOOPS)); }
/** * Usage/leak getter sub-routine * * @return array */ private function _getUsage() { $usage = $this->_helper->getRealMemoryUsage(); return [$usage, $usage - memory_get_usage(true)]; }