This seems to have been discussed quite a bit. I've tried several things I've found, but no luck.
I have a "hacky" cache built that stores objects received from XML calls. The XML calls proved to take too long on page loads, so a user can push a button in the admin to rebuild the cache. The cache routine keeps dying with a memory allocation error.
I know this is a very vague question, but I'm not sure it would help to post a big section of code either.
I am "unsetting" every varaible after I finish using it. I'm calling gc_collect_cycles() which doesn't seem to do anything at all.
I have two anonymous functions that get called over an over....could these be the culprits?
What should I be looking for? Would doing a sleep() help at all?
Code Edit
Here is the code: http://pastebin.com/8M1Dk73E
On line 79 of the pastebin code, I'm calling gc_collect_cycles. Not sure if that is a good place to put it or not.
I am using foreach loops instead of for loops, which I know makes a huge difference with objects being copied, but I would think if I unset the variables it should work the same even if the execution time is longer.
Well, I'm at a loss, so any thoughts would be helpful.