Peter Horne
Peter Horne

Reputation: 6846

Debugging PHP application after exit is called

I have a PHP application that is using a very modest amount of memory until exit is called; at which point the memory usage spikes dramatically causing a fatal error due to exceeding the memory limit.

Is there any way to debug what the application/PHP is doing after exit is called? Alternatively, are there any common reasons for a massive increase in memory to occur at this time? The output buffers are empty when the script is terminated.

Upvotes: 3

Views: 73

Answers (2)

Ghost-Man
Ghost-Man

Reputation: 2187

If you have a loop and for some logical reason it becomes an infinite loop, depending upon operations inside the loop e.g. mathematical operations, assignments etc, there can also be an increase in memory consumption.

Upvotes: 0

Mark Baker
Mark Baker

Reputation: 212402

You can register a shutdown function that will be executed when your script terminates, and that can be used to log memory usage, but I'm not sure how helpful it will be.

Do you have any unusual object __destruct() methods that might be grabbing memory as objects are destroyed? e.g. data writers.

Upvotes: 1

Related Questions