One of our sync servers started throwing a “Fatal error: Allowed memory size of 16777216 bytes exhausted” when dealing with some large data sets. We easily fixed it by bumping up the php.ini memory_limit setting.
It seems that the default 16Mb was a pretty low setting and it was probably inevitable that it would need to be bumped up. But it made me wonder why one server call would need 16Mb of ram. It wasn’t due to a file upload, which is a common cause, so it must be something in our code. Just bumping up the ram solves the problem for now but it always irks me to not know what is going on with the code.
I found an interesting article by Alex Netkachov that goes into detail about circular references in the code which is a definite possibility in our code because we use an ORM framework and access our data through a graph. Due to the combination of data relationships and generated code it’s very likely we have circular references like this. Paul M. Jones also writes about the same issue and illustrates a way to deal with it in your classes.
It looks like we will have to do some investigating to see what’s going on with the code and where the bottlenecks are occurring. If you have any tips or utilities that you use for this type of thing, please post a comment.