Log memory usage using declare and ticks in PHP | DaveDevelopment


# function log_memory() {
# $_SESSION['memory'][] = array(
# 'time' => microtime(true),
# 'memory' => memory_get_usage(),
# ); // or insert your logging code here
# }
#
# declare(ticks = 50); // log every 50 ticks (low level instructions)
# register_tick_function('log_memory');
# $var = 'a';
#
# for($i=0;$i<100;$i++) {
# $var .= 'a';
# }
#
# var_dump($_SESSION['memory']);