[ create a new paste ] login | about

Link: http://codepad.org/u6DYZTlu    [ raw code | output | fork ]

PHP, pasted on Apr 8:
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php

function printUsedMemory(&$arr) // <----- explicit, user-land, pass-by-reference
{
    $start_memory = memory_get_usage();

    $arr[0] = 1; // WRITE!

    echo memory_get_usage() - $start_memory; // let's see the memory used whilst reading
}

$x = array_fill(0, 10000, 1);
printUsedMemory($x);


Output:
1
24


Create a new paste based on this one


Comments: