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
debug_backtrace() assertions should be disabled by default #217
Comments
Storing the backtrace of resolved promises is not meant for debugging Amp, but rather for debugging your code. If you double-resolve a promise, it is useful to know the first place that promise was resolved. If your application is running out of memory due to these backtraces, that indicates to me that you're holding onto too many resolved promises. Look for where data may be being read faster than it is being consumed. From your messages in IRC, I suspect you are emitting data in a |
I'm not aware of anywhere I might be doing that, but if that was the case, wouldn't my memory be leaking? It was completely stable (+/- 3MB), neither growing nor shrinking, for 50 minutes straight whilst constantly downloading data (after disabling
You are exactly correct. However, due to my |
|
I just learned, the hard way, that
debug_backtrace()
is called by default in Amp. After hitting consistent memory limit errors, I went through the painful process of memory debugging PHP - a process I wouldn't wish on my worst enemy - to figure out what was going wrong, and to my dismay, discovered massive memory allocation was happening in innocuous-looking assertions throughout Amp, particularly inPlaceholder
andDeferred
. Turning this feature off by settingAMP_DEBUG=0
was enough to fix the issue, but to save someone else having to go through similar pain, I suggest it should be off by default.Perhaps someone was thinking that it would be sufficient to recommend assertions be disabled if you don't want this feature, but in case that is what you're thinking, I'm going to pre-empt that by suggesting that would be wrong because a developer may wish to use assertions in their own code without debugging Amp.
Calling
debug_backtrace()
is not a sane default because it was causing memory usage to balloon to roughly double in my application, resulting in fatal errors.The text was updated successfully, but these errors were encountered: