diff --git a/core/lib/Drupal/Core/Cache/ApcuBackend.php b/core/lib/Drupal/Core/Cache/ApcuBackend.php
index e04e014..ec0ed30 100644
--- a/core/lib/Drupal/Core/Cache/ApcuBackend.php
+++ b/core/lib/Drupal/Core/Cache/ApcuBackend.php
@@ -176,7 +176,12 @@ public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANEN
     $cache->data = $data;
 
     // Expiration is handled by our own prepareItem(), not APCu.
-    apcu_store($this->getApcuKey($cid), $cache);
+    if (! @apcu_store($this->getApcuKey($cid), $cache)) {
+      file_put_contents(\Drupal::root() . '/sites/default/files/simpletest/apcu-usage.log', date('YmdHis') . ';A;' . $this->getApcuKey($cid) . ';' . strlen($data) . PHP_EOL, FILE_APPEND | LOCK_EX);
+      if (!file_exists(\Drupal::root() . '/sites/default/files/simpletest/apcu-usage.log')) {
+        file_put_contents(\Drupal::root() . '/sites/default/files/simpletest/apcu-usage.log', date('YmdHis') . ';D;' . $this->getUsage() . PHP_EOL, FILE_APPEND | LOCK_EX);
+      }
+    }
   }
 
   /**
@@ -270,4 +275,67 @@ protected function getIterator($search = NULL, $format = APC_ITER_ALL, $chunk_si
     return new \APCUIterator($search, $format, $chunk_size, $list);
   }
 
+  protected function getUsage() {
+    // script from https://www.drupal.org/project/drupal/issues/2765271#comment-12266468
+    function sort_sizes($keyed_sizes) {
+      $sorted = $keyed_sizes;
+      $sizes = array_values($sorted);
+      sort($sizes);
+      array_multisort($sorted, SORT_DESC, $sizes);
+      return $sorted;
+    }
+    function print_size($bin, $size) {
+      $round_by = $size < 1024 ? 1 : 0;
+      return str_pad(round($size/1024, $round_by) . "k", 5) . " - " . $bin . "\n";
+    }
+
+    $output = '';
+    $prefix_sizes = [];
+    $cache_list = array_values(apc_cache_info()["cache_list"]);
+    foreach ($cache_list as $item) {
+      $prefix = preg_filter("/(drupal\.[^.:]+).*/", '$1', $item["info"]);
+
+      if (!isset($prefix_sizes[$prefix])) $prefix_sizes[$prefix] = [];
+
+      $prefix_sizes[$prefix][$item["info"]] = $item["mem_size"];
+    }
+    
+    $sizes_by_bin = [];
+    foreach ($prefix_sizes["drupal.apcu_backend"] as $prefix => $size) {
+      $parts = array_values(array_filter(preg_split("/[:\.]/", $prefix)));
+      $index_of_hash = 0;
+      foreach ($parts as $idx => $part) {
+        if (strlen($part) === 64) {
+          break;
+        }
+        else {
+          $index_of_hash++;
+        }
+      }
+      $bin = implode(":", array_slice($parts, $index_of_hash + 1, 3));
+
+      if (!isset($sizes_by_bin[$bin])) $sizes_by_bin[$bin] = 0;
+      $sizes_by_bin[$bin] += $size;
+    }
+    
+    $total_user = array_reduce(array_values($prefix_sizes), function ($total, $sizes) {
+      return $total + array_sum(array_values($sizes));
+    }, 0);
+
+    $output .= "Free: " . round(apc_sma_info()["avail_mem"]/1024/1024, 2) . "MB\n";
+    $output .= "Total user: " . round($total_user/1024/1024, 2) . "MB\n\n";
+
+    foreach (sort_sizes($prefix_sizes) as $prefix => $sizes) {
+      $output .= print_size($prefix, array_sum(array_values($sizes)));
+    }
+
+    $output .= "\n";
+    $output .= "apcu_backend by prefix:";
+    $output .= "\n\n";
+    foreach (sort_sizes($sizes_by_bin) as $bin => $size) {
+      $output .= print_size($bin, $size);
+    }
+
+    return $output;
+  }
 }
