Memcache不会刷新或清除内存 [英] Memcache won't flush or clear memory

查看:85
本文介绍了Memcache不会刷新或清除内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试清除自己的内存缓存,因为我注意到使用ps -aux时该存储几乎占据了服务器内存的30%.

I've been trying to clear my memcache as I'm noticing the storage taking up almost 30% of server memory when using ps -aux.

所以我运行了以下php代码.

So I ran the following php code.


$memcache = new Memcache;
    $memcache->connect("localhost",11211);
    $memcache->flush();
    print_r($memcache->getStats());

这将导致

(
    [pid] => 4936
    [uptime] => 27318915
    [time] => 1255318611
    [version] => 1.2.2
    [pointer_size] => 64
    [rusage_user] => 9.659531
    [rusage_system] => 49.770433
    [curr_items] => 57864
    [total_items] => 128246
    [bytes] => 1931734247
    [curr_connections] => 1
    [total_connections] => 128488
    [connection_structures] => 17
    [cmd_get] => 170288
    [cmd_set] => 128246
    [get_hits] => 45464
    [get_misses] => 124824
    [evictions] => 1009
    [bytes_read] => 5607431213
    [bytes_written] => 1806543589
    [limit_maxbytes] => 2147483648
    [threads] => 1
)

这应该是相当基本的,但是很明显,我缺少了一些东西.

This should be fairly basic, but clearly, I'm missing something.

推荐答案

您确实需要更改内存缓存设置,以免占用过多内存.启动memcached时,可以使用-m标志向其传递应使用的内存量(以兆字节为单位).有关信息,请参见其文档.

You really need to change the memcached settings so that it doesn't use up as much memory. When you start memcached, you can pass it the amount of memory it should use, in megabytes, using the -m flag. See its documentation for information.

flush只是使高速缓存中的所有项目无效,它不会命令memcached取消分配或取消保留其正在使用的内存.我怀疑您是否可以命令memcached取消分配它正在使用的内存.

flush just invalidates all of the items in the cache, it doesn't command memcached to deallocate or unreserve the memory it is using. I doubt that you can command memcached to deallocate the memory it is using.

这篇关于Memcache不会刷新或清除内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆