what happens with memory when I throw an exception?

Posted by Vincenzo on Stack Overflow See other posts from Stack Overflow or by Vincenzo
Published on 2010-06-16T17:34:49Z Indexed on 2010/06/16 17:52 UTC
Read the original article Hit count: 89

Filed under:

This is the code (just a simplification of a real problem):

<?php
echo memory_get_usage() . "\n";
function f() {
    throw new Exception();
}
function foo() {
    try {
        f();
    } catch (Exception $e) {
    }
}
foo();
echo memory_get_usage() . "\n";

This is the output (PHP 5.3):

630680
630848

What happened with memory (168 bytes lost)? The exception object is not destroyed? Please, help! Thanks

© Stack Overflow or respective owner

Related posts about php