View Full Version : Determining memory used by an array
09-05-2007, 08:28 PM
Is there any way I can determine the amount of memory used by an array?
For instance, if I did a database lookup that returned 100,000 integers into one big array. How can tell how much memory that is taking up?
09-05-2007, 09:23 PM
Not really possible.
ralph l mayo
09-06-2007, 01:01 AM
You can measure the memory used in the whole process of creating and storing the array:
$initial_mem = memory_get_usage();
/* do some stuff here to set up the array */
echo 'Cost of the array + whatever other uncollected structs we incurred building it: ' . (memory_get_usage() - $initial_mem);
edit: I don't know if that function is portable or not. Works on Linux.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.