Index: /trunk/server/items.c
===================================================================
--- /trunk/server/items.c (revision 739)
+++ /trunk/server/items.c (revision 740)
@@ -28,10 +28,17 @@
 
 #define LARGEST_ID 255
+typedef struct {
+    unsigned int evicted;
+    unsigned int outofmemory;
+} itemstats_t;
+
 static item *heads[LARGEST_ID];
 static item *tails[LARGEST_ID];
+static itemstats_t itemstats[LARGEST_ID];
 static unsigned int sizes[LARGEST_ID];
 
 void item_init(void) {
     int i;
+    memset(itemstats, 0, sizeof(itemstats_t) * LARGEST_ID);
     for(i = 0; i < LARGEST_ID; i++) {
         heads[i] = NULL;
@@ -98,5 +105,8 @@
          */
 
-        if (settings.evict_to_free == 0) return NULL;
+        if (settings.evict_to_free == 0) {
+            itemstats[id].outofmemory++;
+            return NULL;
+        }
 
         /*
@@ -107,12 +117,16 @@
          */
 
-        if (tails[id] == 0) return NULL;
+        if (tails[id] == 0) {
+            itemstats[id].outofmemory++;
+            return NULL;
+        }
 
         for (search = tails[id]; tries > 0 && search != NULL; tries--, search=search->prev) {
             if (search->refcount == 0) {
-               if (search->exptime == 0 || search->exptime > current_time) {
-                       STATS_LOCK();
-                       stats.evictions++;
-                       STATS_UNLOCK();
+                if (search->exptime == 0 || search->exptime > current_time) {
+                    itemstats[id].evicted++;
+                    STATS_LOCK();
+                    stats.evictions++;
+                    STATS_UNLOCK();
                 }
                 do_item_unlink(search);
@@ -121,5 +135,8 @@
         }
         it = slabs_alloc(ntotal, id);
-        if (it == 0) return NULL;
+        if (it == 0) {
+            itemstats[id].outofmemory++;
+            return NULL;
+        }
     }
 
@@ -312,5 +329,5 @@
 
 char *do_item_stats(int *bytes) {
-    size_t bufleft = (size_t) LARGEST_ID * 80;
+    size_t bufleft = (size_t) LARGEST_ID * 160;
     char *buffer = malloc(bufleft);
     char *bufcurr = buffer;
@@ -325,6 +342,11 @@
     for (i = 0; i < LARGEST_ID; i++) {
         if (tails[i] != NULL) {
-            linelen = snprintf(bufcurr, bufleft, "STAT items:%d:number %u\r\nSTAT items:%d:age %u\r\n",
-                               i, sizes[i], i, now - tails[i]->time);
+            linelen = snprintf(bufcurr, bufleft,
+                "STAT items:%d:number %u\r\n"
+                "STAT items:%d:age %u\r\n"
+                "STAT items:%d:evicted %u\r\n"
+                "STAT items:%d:outofmemory %u\r\n",
+                    i, sizes[i], i, now - tails[i]->time, i,
+                    itemstats[i].evicted, i, itemstats[i].outofmemory);
             if (linelen + sizeof("END\r\n") < bufleft) {
                 bufcurr += linelen;
