Forum Moderators: coopster

Message Too Old, No Replies

Very strange PHP "Allowed memory size exhausted" error

Regardless of limit in php.ini, every script runs out of memory.

         

yaix2

5:35 am on May 17, 2010 (gmt 0)

10+ Year Member



I have a very strange problem with PHP. It complains about "Allowed memory size of x bytes exhausted", regardless what limit is set in php.ini.

Even stranger is how it started. I imported some csv-files into a database. To do that, I set the memory limit in php.ini to some 512MB and the execution time to some 2 hours.

The script ran out of memory after 90 minutes, and since then, EVERY script runs out of memory! Even a phpinfo() script, complaining of an "Allowed memory size of 262144 bytes exhausted" (sometimes even smaller byte amounts). The php.ini value is still at 512MB, so where does PHP get those limits from?

Thanks for any hints!

Matthew1980

10:10 am on May 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there yaix2,

Have you still got the same problem if you revert back to the defaults. Always good to make a copy of the original ini file just incase it gets wrecked. You do need to restart apache when you alter anything in the ini file.

Cheers,
MRb

Readie

10:40 am on May 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It might also be your hosting provider giving you a bit of a smack-down for using so many system resources. Send them an E-mail asking for details.

yaix2

10:59 am on May 17, 2010 (gmt 0)

10+ Year Member



@Matthew1980: Yes, I changed it back to defaults (only had edited the memory limit) and tried some other values too. Every time I restarted Apache, even tried to restart the PC. Same problem.

@Readie: That problem is luckily happening on my local develpment box, not on the live system :)

Matthew1980

1:05 pm on May 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there yaix2,

Check the error logs from the apache side of things, this may shed some light on the root of the problem, if needs be though and as it's a local install, back up your site/project data, and any data from the mysql side of things too (would be better if you have a backup of the sql from before you uploaded the CSV file), then do a reinstall if your using WAMPP/XAMPP this should be a 20 minute job - failing that, always good to have another machine to work on!

Cheers,
MRb

jatar_k

1:17 pm on May 17, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



have you restarted since encountering this issue?

if not then you are probably still out of mem

yaix2

1:51 pm on May 17, 2010 (gmt 0)

10+ Year Member



@jatar_k: yes, that was my first guess, too. I restarted apache and the pc, no luck.

@Matthew1980: I'm on Ubuntu. I'll try re-install of the php5 and related packages. Hope that helps :)

The strange thing is, that it just stopped working, without me changing anything. It ran out of memory at half a gigabyte, and after that happened, now it runs out of memory at only a few kilobytes. Without any change to a config or ini file.

jatar_k

2:32 pm on May 17, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



did it exhaust the disk space? if so is there a partial file lying around so the drive is still full?

Matthew1980

2:35 pm on May 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there yaix2,

I am by no means guaranteeing as this will stop the problem reoccuring when you re install, but as you are on ubuntu, LAMPP will be your best bet, I ran it for a month, but got annoyed with the complexity of just unzipping the installer - nearly 3 hours! But as a package it's just like running WAMP, I think XAMPP is just as good though, thats what I run now I think, just saves installing everything as seperate programmes IMO.

I agree though, does sound as though there is an issue somewhere in your setup, just make sure as you back up before you attempt anything drastic.

Hope your sorted soon anyway :)

Cheers,
MRb

yaix2

2:37 pm on May 17, 2010 (gmt 0)

10+ Year Member



@jatar_k: No, there is still plenty of space on the disk. What do you mean by partial file?

jatar_k

2:43 pm on May 17, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I was wondering if the csv files might still be lying around

I don't know, awful strange, some process still running? didn't get killed properly, though a restart should have fixed that and cleaned up memory

another thought is an error, I have seen this with upload scripts where they return errors that are unrelated to the issue at hand. Approach from the server side and see if something has changed there, permissions maybe?

yaix2

3:11 pm on May 17, 2010 (gmt 0)

10+ Year Member



No upload, just reading 3 large csv files, re-organizing the lines and add them to a database (inside Drupal). But, as I said, not even phpinfo() would run anymore.

However, I just reinstalled php5-common and libapache2-mod-php5 packages, restarted, and now at least php seems to work again (thanks Matthew1980!), but does not want to connect to mysql anymore. But that should be a solvable problem, I hope.

Still not sure what had actually happend though...

Thanks all for your help!

Matthew1980

3:30 pm on May 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there yaix2,

Lets hope it is solveble! Glad as you are almost there anyway.

Cheers,
MRb

yaix2

4:03 pm on May 17, 2010 (gmt 0)

10+ Year Member



After removing every library that had "php" in it's name and reinstalling it, now it works again.

Matthew1980

6:39 pm on May 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Yaix2,

Happy coding then!

Cheers,
MRb