PHP out of memory error with but no line number given for the error

I’ve written a small survey app for a client, nothing particularly complicated, that asks some questions of a client and then records the answers in a database. It works perfectly on my computer, a development server that we have and the clients staging server. However on the clients live server we keep getting the following error:

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 289839120 bytes) in Unknown on line 0

I really don’t know what’s causing this issue and the client seems unable to diagnose it either. My computer is running Windows 7 with Apache and PHP 5.3.6 running as an Apache module. Our development server is running Linux with Apache and PHP 5.2.16 installed as an Apache module. Both of the clients servers (staging and live) are running on Linux VPS (although I’m not sure if staging and live are running on the same VPS) with PHP 5.2.14 running using CGI. All of the environments are running a standard set of extensions, except for my computer which has a few things like the APC and HTTP extensions installed. The memory limit on the clients VPS is 256M.

I believe there must be some issue with the configuration on the clients server (they’re running Joomla on this server for their website alongside this small survey app I’ve created), although I’m not ruling out problems with my code. The reason I’m leaning towards this diagnosis is that the code runs with no problems on other environments, is doing nothing that would eat lots of memory and that the out of memory error is pointing to file ‘unknown on line 0’.

I’d really appreciate any thoughts anyone may have on this problem.

Answer

Allowed memory size of 268435456 bytes exhausted

There’s something very wrong going on here.

I believe there must be some issue with the configuration on the clients server

You have provided no reason for your belief.

First thing I’d be looking at is the SQL this is running and the slow query log; at a guess you’re fetching way too much data from the database.

If that doesn’t solve the problem then setup instrumentation in the code to pick a subset of requests and log memory usage throughout their progress.

Attribution
Source : Link , Question Author : Jeremy , Answer Author : symcbean

Leave a Comment