Skip to content

Memory leak #4922

Description

@stubbornbe

System layout
OS: Debian 13.5
Webserver: Apache 2.4.67
Php: 8.4
PhpSpreadsheet: 5.8.0

Problem
PhpSpreadsheet doesn't release any memory after script end.

Minimalistic script showing issue

$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
$reader->setReadDataOnly(true);
$reader->setLoadSheetsOnly(["MyTab", "MyTab"]);
$worksheet = $reader->load($_FILES['excel']['tmp_name']);

+++Here I should execute some code, but even when I do absolutely nothing here, I already get this behavior+++

$worksheet->disconnectWorksheets();
unset($worksheet);
unset($reader);
\PhpOffice\PhpSpreadsheet\Settings::getCache()->clear();
gc_collect_cycles();

Every time I run this script to read an xlsx file, system memory grows significantly. (No problem with that.)
When the above script ends, no memory is released at all.
After a couple of runs all system memory is in use and the entire OS locks on heavy swapping.
I can't find a way to force a memory release other than an Apache restart.
What could be locking? I'm only opening and reading the document.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions