简体   繁体   中英

Troubleshooting memory leaks

I have set my PHP MAMP server to a maximum of "256M" in the php.ini but am suddenly getting a memory error. There are two things that are strange about this:

  1. This is a shockingly high amount of memory for a script to use. Maybe I'm too easily shocked but should scripts be running over 256M? I wouldn't have thought so.
  2. Even though I've now changed my setting to "512M" I still get the memory error and it still reports running out in/around the 256M range (as if my setting is being ignored). I did recycle the web server which I figured would be enough to get the new settings into play.

The exact message I'm getting is this:

[25-Oct-2012 14:27:53] PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 222300161 bytes) in [FILE_PATH]/wp-content/themes/lifegadget-pagelines/sections/lg_content/section.php on line 42
[25-Oct-2012 14:27:53] PHP Fatal error:  Call to a member function get() on a non-object in [FILE_PATH]/wp-content/object-cache.php on line 52

So my questions are as follows:

  1. Troubleshooting . Is there any way to troubleshoot memory usage?
  2. Scale . Is exceeding a 256M limit a clear problem or is this justified in some cases?
  3. New Ceiling . Why is my new ceiling of 512M being ignored? Not that I'm happy to have it stay at 512M but I would have thought it would at least get me back up and running (I have 16GB on the machine so there's plenty of physical memory).

Infinite loop can cause this or if you have circular references with pre 5.3 PHP version. See: Garbage collection

Inject this function ini_set('memory_limit', -1); at the very beginning of your suspected memory leaking class/page, this is a temporary solution to get things working but it won't help you know where exactly your script is leaking memory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM