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

PHP Fatal error: Allowed memory size of xx bytes exhausted in GzipEncoderPlugin.php #1552

Closed
chrisc0 opened this issue Jun 20, 2023 · 3 comments

Comments

@chrisc0
Copy link

chrisc0 commented Jun 20, 2023

How do you use Sentry?

Sentry Saas (sentry.io)

Version

3.18.2

Steps to Reproduce

I'm not exactly sure how to reproduce the error. Why is one of your plugins throwing this error?

PHP message: PHP Fatal error: Allowed memory size of 471859200 bytes exhausted (tried to allocate 65536 bytes) in /var/www/sites/xx/vendor/sentry/sentry/src/HttpClient/Plugin/GzipEncoderPlugin.php on line 53

Expected Result

No error

Actual Result

PHP message: PHP Fatal error: Allowed memory size of 471859200 bytes exhausted (tried to allocate 65536 bytes) in /var/www/sites/xx/vendor/sentry/sentry/src/HttpClient/Plugin/GzipEncoderPlugin.php on line 53

@stayallive
Copy link
Collaborator

This is most likely because either you have a lot of information in the event (huge stacktrace, many breadcrumbs, lot's of context) and you might alreay be memory constraint which results in the application running out of memory when trying to send the event to Sentry.

Part of sending the event to Sentry is gzipping the event data since the Sentry server only accepts payloads below a certain size and the gzipping helps with staying below that limit and speeding up the network transfer too. It can be disabled by setting enable_compression to false in the SDK options, however I would suggest to be careful since that could have uninteded side effects where events might be dropped because they exceed the size accepted by Sentry.

Have you tried to reproduce the event being sent and see what data is contained within and if it might be excessively large?

@chrisc0
Copy link
Author

chrisc0 commented Jun 21, 2023

How do I see what data is in the event?
Also, I tried adding another 25MB to the server but I'm still getting the error. The frustrating part is that if I disable Sentry, my application runs just fine. Sentry itself seems to be causing the problem here.

@stayallive
Copy link
Collaborator

You can use the before_send option to get the Event instance we would transmit to Sentry: https://docs.sentry.io/platforms/php/configuration/filtering/#using-platformidentifier-namebefore-send-

Since you are not using a framework it's a little tricky considering what would be in those events since you implemented them yourself it would be interesting if you can pinpoint the exact problem event to see if there might be some kind of recursive issue or if there is something interesting on the request where the problem is being triggered, like if it is a POST request with a large payload. If it's not a manually triggered event it's most likely a PHP Error like a NOTICE or WARNING (or many of them) being (attempted) to sent to Sentry.

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

No branches or pull requests

3 participants