{"record":{"id":"a0b5fc522264c4d5","repo":"Leantime/leantime","slug":"notification-plugin-zip-malloc","errorCode":null,"errorMessage":"notification.plugin_zip_malloc","messagePattern":"notification\\.plugin_zip_malloc","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"app/Domain/Plugins/Services/Plugins.php","lineNumber":738,"sourceCode":"\n        if (\n            is_dir($pluginDir = \"{$this->pluginDirectory}{$foldername}\")\n            && ! File::deleteDirectory($pluginDir)\n        ) {\n            throw new \\Exception(__('notification.plugin_cant_remove'));\n        }\n\n        if (! mkdir($pluginDir) && ! is_dir($pluginDir)) {\n            throw new \\RuntimeException(sprintf('Directory \"%s\" was not created', $pluginDir));\n        }\n\n        $zip = new \\ZipArchive;\n\n        match ($zip->open($temporaryFile)) {\n            \\ZipArchive::ER_EXISTS => throw new \\Exception(__('notification.plugin_zip_exists')),\n            \\ZipArchive::ER_INCONS => throw new \\Exception(__('notification.plugin_zip_inconsistent')),\n            \\ZipArchive::ER_INVAL => throw new \\Exception(__('notification.plugin_zip_invalid_arg')),\n            \\ZipArchive::ER_MEMORY => throw new \\Exception(__('notification.plugin_zip_malloc')),\n            \\ZipArchive::ER_NOENT => throw new \\Exception(__('notification.plugin_zip_no_file')),\n            \\ZipArchive::ER_NOZIP => throw new \\Exception(__('notification.plugin_zip_not_zip')),\n            \\ZipArchive::ER_OPEN => throw new \\Exception(__('notification.plugin_zip_cant_open')),\n            \\ZipArchive::ER_READ => throw new \\Exception(__('notification.plugin_zip_read_err')),\n            \\ZipArchive::ER_SEEK => throw new \\Exception(__('notification.plugin_zip_seek_err')),\n            default => throw new \\Exception(__('notification.plugin_zip_unknown_err')),\n            true => null,\n        };\n\n        if (! $zip->extractTo($pluginDir)) {\n            throw new \\Exception(__('notification.plugin_zip_cant_extract'));\n        }\n\n        $zip->close();\n\n        unlink($temporaryFile);\n\n        // read the composer.json content from the plugin phar file","sourceCodeStart":720,"sourceCodeEnd":756,"githubUrl":"https://github.com/Leantime/leantime/blob/9a9f49f1008f4782b30f6723c54228f4f992e636/app/Domain/Plugins/Services/Plugins.php#L720-L756","documentation":"The match maps ZipArchive::ER_MEMORY to 'Zip: Malloc failure'. libzip could not allocate the memory it needs to index the archive while opening it. This is not about the zip being bad - it is the PHP process hitting its memory ceiling (memory_limit) or a container cgroup memory cap during open().","triggerScenarios":"installMarketplacePlugin() opening a large plugin zip under a low memory_limit (shared hosting defaults of 64-128M are common victims), or a container whose memory cgroup limit is near exhaustion; memory pressure from other concurrent requests finishing the budget.","commonSituations":"Shared hosting with low memory_limit installing asset-heavy plugins; Kubernetes pod memory limits; php.ini memory_limit left at a small value for the web SAPI while CLI has a higher one.","solutions":["Check the web SAPI's actual limit: php -r via a phpinfo page or ini_get('memory_limit') rendered from a route - raise it (e.g. 512M) for the install.","Raise the container/pod memory limit if the process is being OOM-capped.","Retry the install when the server is less loaded (other requests consume the same limit).","If a custom build has no zlib support, verify the zip extension is fully functional: php -m | grep zip."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"$limit = ini_get('memory_limit');\nif ($limit !== '-1' && parseByteSize($limit) < 256 * 1024 * 1024) {\n    ini_set('memory_limit', '512M'); // raise for the duration of the plugin install\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set memory_limit of at least 256-512M for requests that install plugins.","Check the web SAPI's limit (not CLI's) - they differ.","Size container memory limits with plugin installs in mind."],"tags":["plugins","ziparchive","memory","marketplace"],"backgroundTag":"php-memory-limit-exceeded","analyzedSha":"9a9f49f1008f4782b30f6723c54228f4f992e636","analyzedAt":"2026-08-21T02:37:38.966Z","schemaVersion":2},"datasetVersion":"2026-08-21T03:17:12.404Z"}