Php get memory size of variable

You can't retrospectively calculate the exact footprint of a variable as two variables can share the same allocated space in the memory

Let's try to share memory between two arrays, we see that allocating the second array costs half of the memory of the first one. When we unset the first one, nearly all the memory is still used by the second one.

echo memory_get_usage[]."\n"; // 

Chủ Đề