"zend_mm_heap corrupted" when using "exit;"


Like the title says. I basically have a very simple RestResponse() to which I can setContent($content) and then run sendAndExit() which sends an application/json content header, echoes the content and then exits.

Problem is, the line "exit;", the final line in the sendAndExit()-method sometimes causes zend_mm_heap corrupted errors in Apache, and I have been unable to figure out why. It doesn't happen every time, but sometimes I make a change to the code and this error pops up.

I've been trying to find explanations to this issuer here and there, and basically, they all say whats obvious: the Zend Memory Manager memory heap has been corrupted and the response cannot be sent.

If I remove the exit; at the end of this function, the problem does not occur.

Has anyone experienced / solved this problem, and if so, how did you manage to solve it?

Thanks for your time.

Best regards, dimhoLt

This looks to me like you are trying to reinvent the wheel and having some troubles.

Have you looked into using a phalcon response? http://docs.phalconphp.com/en/latest/api/Phalcon%5Http%5Response.html

$response = new Phalcon\Http\Response();
$response->setStatusCode(200, "OK");

From your description it sounds like you have created a more difficult abstraction then just using the tools availible. Let me know if this helps.

You may also want to look at how others have structured an API: