Skip to content

eval is leaking memory #8078

Open
Open
@mvorisek

Description

@mvorisek

Description

The following code:

<?php

$m = memory_get_usage();
for ($i = 0; $i < 1000; $i++) {
    $fn = eval('return function ($foo) {};');
    //$fn = function ($foo) {};
    var_dump(memory_get_usage() - $m);
}

https://3v4l.org/LF4Ri
https://3v4l.org/1DeC6 - /wo eval, not leaking
https://3v4l.org/NtIrU - eval /wo anonymous function is not leaking

Resulted in this output:

int(640)
int(672)
int(672)
int(672)
...
int(197280)

But I expected this output instead:

int(640)
int(672)
int(672)
int(672)
...
int(672)

PHP Version

8.1.x

Operating System

any

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions