Memcached 使用超过最大内存

ay4*_*you 2 memcached memory-management

我在 memcache 上安装了一个安装程序,我想在生产环境中使用它,但是当我运行了一些测试时,似乎 memcache 不会释放内存,即使它用完了所有分配的内存,我也登录了并运行了flush_all命令,但对象仍在缓存中。这是一些测试的输出


memcached-tool

memcache-top v0.6       (default port: 11211, color: on, refresh: 3 seconds)

INSTANCE                USAGE   HIT %   CONN    TIME    EVICT/s READ/s  WRITE/s

127.0.0.1:11211         427.1%  0.0%    18      1.4ms   0.0     244     261.0K

AVERAGE:                427.1%  0.0%    18      1.4ms   0.0     244     261.0K

TOTAL:          4.3MB/  1.0MB           18      1.4ms   0.0     244     261.0K
Run Code Online (Sandbox Code Playgroud)
memcached-tool 127.0.0.1:11211 display


  No  Item_Size  Max_age   Pages   Count   Full?  Evicted Evict_Time OOM

  1     560B         4s       1    1872     yes        0        0 15488

  2     704B        32s       1     559      no        0        0    0

  3     880B         4s       1    1191     yes        0        0 1335

  4     1.1K         9s       1     116      no        0        0    0

  5     1.4K        21s       1      14      no        0        0    0

  6     1.7K         4s       1      17      no        0        0    0

  7     2.1K        84s       1      24      no        0        0    0

  8     2.7K       130s       1      60      no        0        0    0

  9     3.3K        25s       1     290      no        0        0    0

 10     4.2K         9s       1     194      no        0        0    0

 11     5.2K         9s       1     116      no        0        0    0

 15    12.7K       816s       1       1      no        0        0    0

 16    15.9K       769s       1       5      no        0        0    0

 18    24.8K       786s       1       1      no        0        0    0

 21    48.5K       816s       1       1      no        0        0    0
Run Code Online (Sandbox Code Playgroud)

memcached-tool 127.0.0.1:11211 统计信息

 127.0.0.1:11211   Field       Value

     accepting_conns           1

           auth_cmds           0

         auth_errors           0

               bytes     4478060

          bytes_read    23964596

       bytes_written   546642860

          cas_badval           0

            cas_hits           0

          cas_misses           0

           cmd_flush           0

             cmd_get      240894

             cmd_set        4504

         conn_yields           0



  connection_structures          21

    curr_connections          18

          curr_items        4461

           decr_hits           0

         decr_misses           0

         delete_hits           0

       delete_misses           0

           evictions           0

            get_hits       43756

          get_misses      197138

           incr_hits           0

         incr_misses           0

      limit_maxbytes     1048576

 listen_disabled_num           0

                 pid        8731

        pointer_size          64

           reclaimed           0

       rusage_system    5.047232

         rusage_user    4.311344

             threads           4

                time  1306247929

   total_connections        3092

         total_items        4504


              uptime        1240

             version       1.4.5
Run Code Online (Sandbox Code Playgroud)

小智 5

-m 告诉 memcached 用于项目存储的 RAM 量(以兆字节为单位)。请注意,这不是全局内存限制,因此 memcached 将使用比您指定的多百分之几的内存。将其设置为安全值。将其设置为小于 48 MB 在 1.4.x 及更早版本中无法正常工作。它仍然会使用内存。

来源: https: //github.com/memcached/memcached/wiki/ConfiguringServer#commandline-arguments