Did a quick search on the forum; but could not find the exact information I'm looking for. Yesterday we ran into 'out of memory' errors; because PHP was consuming about 80 MB of data. It was because of an add-on.
I'm however curious to know what exactly should be our php memory setting? How do we decide it?
Out of memory means that PHP couldn't allocate memory. Either you have an allocation limit smaller than PHP's limit or your server is out of memory (or couldn't allocate it for some reason).
Assuming it's a legit out of memory issue, the specifics of what to do vary a lot, but they do involve analyzing how much memory an active connection takes. If you can't reduce that (depending on configuration), you need to consider reducing the maximum number of active connections to prevent overloading the server or simply adding more memory.
There is no magic number. Allocate as much as you possibly can. If you have 32GB of RAM, are you really going to allocate 128M or 256M to PHP? That's just plain silly. There's no optimum size, there's no general rule, there's no magic number.