Re: Byte Size of an array
| From: | Eric Butera | Date: | Tue, 08 Jan 2008 14:18:52 +0000 |
| Subject: | Re: Byte Size of an array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-266875@lists.php.net to get a copy of this message | ||
On Jan 7, 2008 3:45 AM, Sancar Saran <sancar.saran@evodot.com> wrote:
> Hello,
>
> I just wonder to how can I find a memory size of an array.
>
> Regards
>
> Sancar
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
If you're wondering how much memory your array is taking up engine
wise you can do a few little tests. Of course you could do the echo
serialize form but that isn't going to tell you how much memory it
uses internally within the engine itself. Granted this might not
either, but it is at least a little closer.
var_dump(memory_get_usage());
$array = array(
1 => 'one',
2 => 'two',
3 => 'three'
);
var_dump(memory_get_usage());
Output:
int(53464)
int(53928)
Also Xdebug trace:
Version: 2.0.0
TRACE START [2008-01-08 14:13:17]
1 0 0 0.004355 51968 {main} 1
/Users/eric/Sites/blah.php 0
1 0 1 0.004833 52328
0.0052 23184
TRACE END [2008-01-08 14:13:17]