Intervention / Intervention/image

Memory leaks when using insert function, even with destroy.

Open
#762 3 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

investigation-needed
Dominant language
PHP
Stars
14.4k
Forks
1.5k
Avg merge
17h 51m
Merged PRs (30d)
11

Description

I wrote a laravel command to operate many images, something like that:

while (true) { // use while-true to simulate lots of images
    foreach (Storage::files('tmp') as $file) {
        echo $file, "\n";
        $image = Image::make(storage_path('app/' . $file));
        // $img = Image::make(storage_path('app/' . $file));
        $img = clone($image);
        $img->crop(200, 100);
        // $this->some($img);
        $image->insert($img);
        $image->save(storage_path('tmp.png')); // without this save, grows much slower. It is another encode leaks issue I think.
        $img->destroy(); // without these two destroy, script booms very quickly.
        $image->destroy();
        usleep(25);
    }
}

The memory usage grows about 1M per second on my PC.

By the way, I am using GD2 driver on Windows. Maybe it's an issue of GD? I will try it on Linux later.

Anyidea?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the memory growth from the command example while varying insert(), save(), and destroy() calls with the GD2 driver. Compare behavior on the reported Windows environment and Linux if available; done means identifying whether the leak is in this library's image operations or GD2 and documenting a confirmed fix or limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.