5

zend_mm_heap corrupted is coming up as an error message on a PHP program I wrote to pre-render a large environment.

I suspect it's being caused by having too many variable assignments in the script, although I'm uncertain of this since I wrote the script to only have about 20 variables at any given time, of which one is an array that may hold up to 500 elements. That said, the number of iterations in total is on the order of a few billion.

Am I correct in my suspicion, and if so is there anything that can be done about it? Would it be better, for instance, to run the script for a while, then dump out important variables to a file and restart the script, making it pick up those variables and continuing?

Agi Hammerthief
  • 2,114
  • 1
  • 22
  • 38
Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
  • Have you already looked at this? http://stackoverflow.com/questions/2247977/what-does-zend-mm-heap-corrupted-mean – Matt Browne Feb 25 '13 at 00:31
  • Yes I have. None of the answers seem relevant. I am not using OB, I am using an object but I tried using procedural functions instead and the error still happened, the array's size is explicitly controlled by checking it before adding to it, I'm using Windows, and so on. – Niet the Dark Absol Feb 25 '13 at 00:33
  • Anything in the PHP error log? Sometimes there may be additional info there that wasn't displayed on-screen, even if your script is set to display all errors. – Matt Browne Feb 25 '13 at 00:35
  • Nothing more than the corrupted heap message. No line number or anything. – Niet the Dark Absol Feb 25 '13 at 00:37
  • This was the only thing I found in some Google searching that might be helpful: http://lampmaster.blogspot.com/2009/07/fixing-zendmmheap-corrupted-on-centos.html. But it's quite possible that none of that is relevant in your case. – Matt Browne Feb 25 '13 at 00:44
  • What library are you using to do the rendering? I would have thought it would be a bug in the library somewhere which is corrupting the heap - as that's what the error message means isn't it? – Danack Feb 25 '13 at 01:46
  • I'm not using any library, just native code. I even disabled all extensions and it still happens. – Niet the Dark Absol Feb 25 '13 at 01:51
  • I have met this problem twice on two different servers. zend_mm_heap corrupted followed by segmentation fault in mod_php. Never found a solution though:(. – clime Mar 03 '13 at 15:09
  • Which version of PHP, do you use? Can you enable debug mode somehow? – Th. Ma. Apr 06 '13 at 09:22
  • 1
    Have you tried increasing the available memory in php.ini? If I was to try and fix your code, I would progressively comment hot spots to see when the problem stops, having the program output progress bufferless in the meantime. That said, a multi-billion-cycle code isn't what PHP is for. Consider writing a plugin (mod) for your specific purpose. I can't give you specific help though. – Zdenek Sep 26 '14 at 18:31
  • Did you thought about multi-threading? – S.Pols Dec 04 '14 at 14:53
  • To expand on @Zdenek's comment: Assuming you're using Apache, [this book](http://shop.oreilly.com/product/9781565925670.do) [(PDF version here)](http://eduunix.ccut.edu.cn/index2/pdf/Writing%20Apache%20Modules%20with%20Perl%20and%20C.pdf) might come in handy. – Agi Hammerthief Dec 15 '14 at 09:54
  • This could be a bug in PHP or one of the loaded extensions. Can you show your phpinfo()? How are you running PHP (mod_php, CLI, FastCGI, etc.)? Which version? Which OS? 32/64-bit? How was it built? – Jonathan Amend Dec 16 '14 at 16:40

2 Answers2

0

I've seen this problem, and can reproduce it using phalcon, but it seems to originate from APC cache. I fixed by switching from APC to zend opcache. You can try disabling APC to see if it goes away.

Best I can reason from my investigations is that APC is doing something to memory that zend is using. PS, it doesn't have anything to do with zend framework, it's an error related to the parts of zend that were merged into php.

Peter
  • 145
  • 1
  • 15
0

The solution to your problem is to dowload the latest version of APC compatible with your PHP version.

You'll have to force install it making it overwrite the old version of APC. This will in many cases fix the issue you're having.

Peter
  • 8,776
  • 6
  • 62
  • 95