Details
Description
While attempting to encode large messages, our team found that the PHP run-time would exceed its memory limit and die. Profiling and use of memory_get_usage showed us that we were spending a lot of time in append_str and that the PHP process grew after every call to this method, resulting in the leak-like behavior that caused the process to grow and then crash. We rewrote append_str to use the string concatenation operator instead of the somewhat elaborate scheme in place today (str_split, followed by the copying of one byte at a time from the latter array to the final string) and the memory usage issues disappeared with no loss of functionality. We would like to provide the patch to fix this issue.