以下memcached对象的大小是否会在到达代码末尾时发生变化?
<?php
$m = new Memcached();
$m->addServer('localhost', 11211);
$m->set('array', array(11, 12, 13, 14, 15, 16, 17, 18, 19, 20)); //Size in memory is X
$m->set('array', array(11, 12)); //Size in memory is ?
?>
答案 0 :(得分:1)
是的,它会减少内存
使用memory_get_usage();
打印内存使用情况,您将看到参考
$m->set('array', array(11, 12, 13, 14, 15, 16, 17, 18, 19, 20));
$memory = memory_get_usage();
echo $memory ."<br>"; // it print 235368
$m->set('array', array(11, 12));
$memory = memory_get_usage();
echo $memory ."<br>"; // it print 235504
在您的服务器中试用