diff --git a/.htaccess b/.htaccess
index 83cb71a..d5e9e96 100644
--- a/.htaccess
+++ b/.htaccess
@@ -38,6 +38,7 @@ AddEncoding gzip svgz
   # not set.
   php_value always_populate_raw_post_data   -1
 </IfModule>
+php_value memory_limit 4096M
 
 # Requires mod_expires to be enabled.
 <IfModule mod_expires.c>
diff --git a/index.php b/index.php
index 750dc28..904ed54 100644
--- a/index.php
+++ b/index.php
@@ -20,3 +20,83 @@
 $response->send();
 
 $kernel->terminate($request, $response);
+
+$logfile = $kernel->getAppRoot() . '/sites/default/files/simpletest/mem-index.log';
+$apcuinfo = ';;';
+if (function_exists('apcu_sma_info')) {
+  $info = apcu_sma_info(TRUE);
+  $apcuinfo = $info['avail_mem'].';'.$info['seg_size'].';'.$info['num_seg'];
+}
+file_put_contents($logfile, date('YmdHisO') . ';I;' . memory_get_peak_usage(TRUE) . ';' . $apcuinfo . PHP_EOL, FILE_APPEND | LOCK_EX);
+
+if (date('i') % 5  == 0) {
+  $first = !file_exists($kernel->getAppRoot() . '/sites/default/files/simpletest/apcu-usage-' . date('Hi') . '.log');
+  if ($first) {
+    file_put_contents($kernel->getAppRoot() . '/sites/default/files/simpletest/apcu-usage-' . date('Hi') . '.log', '.', FILE_APPEND | LOCK_EX);
+
+    // 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(apcu_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(apcu_sma_info()["avail_mem"]/1024/1024, 2) . "MB\n";
+    $output .= "Entries: " . count($cache_list) . "\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);
+    }
+
+    file_put_contents($kernel->getAppRoot() . '/sites/default/files/simpletest/apcu-usage.log', date('YmdHisO') . ';D;' . ini_get('memory_limit') . ';' . $output . PHP_EOL, FILE_APPEND | LOCK_EX);
+  }
+
+
+}
\ No newline at end of file
diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php
index 0e7caa3..f749fac 100644
--- a/sites/default/default.settings.php
+++ b/sites/default/default.settings.php
@@ -601,6 +601,7 @@
  * Settings defined there should not be duplicated here so as to avoid conflict
  * issues.
  */
+ini_set('memory_limit', '4096M');
 
 /**
  * If you encounter a situation where users post a large amount of text, and
