Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory limit not throw new RuntimeException #856

Open
Triloworld opened this issue Jan 25, 2024 · 0 comments
Open

Memory limit not throw new RuntimeException #856

Triloworld opened this issue Jan 25, 2024 · 0 comments

Comments

@Triloworld
Copy link

Triloworld commented Jan 25, 2024

This line by default use limited memory:

$resource = imagecreatetruecolor($size->getWidth(), $size->getHeight());

What I get:

  • PHP Error hidden in production application

What we like to get:

  • throw error on screen that memory isn't sufficient

This fix temporary to use all machine memory if application setup is less than needed:

        $memory = ini_get('memory_limit');
        ini_set('memory_limit', '-1');
        $resource = imagecreatetruecolor($size->getWidth(), $size->getHeight());
        ini_set('memory_limit', $memory);

There is solution that throw error when memory size isn't enought:
https://www.php.net/manual/en/function.imagecreatetruecolor.php#99623

@Triloworld Triloworld changed the title Memory limit not controlled Memory limit not throw new RuntimeException Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant