0

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.

Jeremy
  • 126
  • 3
  • Ask to double bump `memory_limit =` and see if you stil get it. Something is taxing the system – random Mar 28 '11 at 14:36
  • @random-do you think it's something outside of the PHP process? If PHP was dying with an out of memory error I would have expected an indication as to the file and line number the problem was in. – Jeremy Mar 28 '11 at 14:39
  • Have you tried this with different code (eg ` echo "Hello World"; ?>`)? If no PHP executes then it's definitely something weird with PHP's configuration (bad module loaded?) – DerfK Mar 28 '11 at 16:25
  • @DerfK-PHP is definitely executing. Some requests load without causing the out of memory error but most of the time we get the error message at the bottom of the page, at the end of the response. – Jeremy Mar 28 '11 at 16:53

1 Answers1

0

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.

symcbean
  • 19,931
  • 1
  • 29
  • 49
  • I'll look some more into the SQL but I'm fetching almost nothing from the db. There is one select statement that fetches a few rows of data from a table with under ten rows in it. As for a reason as to why I think the issue is with server config, the exact same code with the same database runs with no issues on other 3 hosts, at least 2 of which are allocating far less memory to PHP. – Jeremy Mar 28 '11 at 15:13