diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module
index 0e0ea2afd4..31cb171fa5 100644
--- a/core/modules/simpletest/simpletest.module
+++ b/core/modules/simpletest/simpletest.module
@@ -186,9 +186,18 @@ function simpletest_run_phpunit_tests($test_id, array $unescaped_test_classnames
   $phpunit_file = simpletest_phpunit_xml_filepath($test_id);
   simpletest_phpunit_run_command($unescaped_test_classnames, $phpunit_file, $status, $output);
 
+  $mem = '0';
+  if (is_array($output) && count($output)) {
+    $mem = array_filter($output, function($v) { return stripos($v, 'Memory: '); });
+    $mem = !empty($mem) ? explode('Memory: ', array_pop($mem)) : '';
+    $mem = !empty($mem) && is_array($mem) ? array_pop($mem) : '0';
+    $mem = trim(str_ireplace('MB', '', $mem));
+    $mem = (int)(floatval($mem)*1048576);
+  }
+
   $rows = [];
   if ($status == TestStatus::PASS) {
-    $rows = simpletest_phpunit_xml_to_rows($test_id, $phpunit_file);
+    $rows = simpletest_phpunit_xml_to_rows($test_id, $phpunit_file, $mem);
   }
   else {
     $rows[] = [
@@ -242,7 +251,7 @@ function simpletest_summarize_phpunit_result($results) {
         '#pass' => 0,
         '#fail' => 0,
         '#exception' => 0,
-        '#debug' => 0,
+        '#debug' => $result['message'],
       ];
     }
 
@@ -260,7 +269,7 @@ function simpletest_summarize_phpunit_result($results) {
         break;
 
       case 'debug':
-        $summaries[$result['test_class']]['#debug']++;
+        //$summaries[$result['test_class']]['#debug']++;
         break;
     }
   }
@@ -777,7 +786,7 @@ function simpletest_mail_alter(&$message) {
  *   {simpletest}. If the phpunit_xml_file does not have any contents then the
  *   function will return NULL.
  */
-function simpletest_phpunit_xml_to_rows($test_id, $phpunit_xml_file) {
+function simpletest_phpunit_xml_to_rows($test_id, $phpunit_xml_file, $mem = '0') {
   $contents = @file_get_contents($phpunit_xml_file);
   if (!$contents) {
     return;
@@ -785,7 +794,7 @@ function simpletest_phpunit_xml_to_rows($test_id, $phpunit_xml_file) {
   $records = [];
   $testcases = simpletest_phpunit_find_testcases(new SimpleXMLElement($contents));
   foreach ($testcases as $testcase) {
-    $records[] = simpletest_phpunit_testcase_to_row($test_id, $testcase);
+    $records[] = simpletest_phpunit_testcase_to_row($test_id, $testcase, $mem);
   }
   return $records;
 }
@@ -841,8 +850,8 @@ function simpletest_phpunit_find_testcases(\SimpleXMLElement $element, \SimpleXM
  * @return array
  *   An array containing the {simpletest} result row.
  */
-function simpletest_phpunit_testcase_to_row($test_id, \SimpleXMLElement $testcase) {
-  $message = '';
+function simpletest_phpunit_testcase_to_row($test_id, \SimpleXMLElement $testcase, $mem = '0') {
+  $message = $mem;
   $pass = TRUE;
   if ($testcase->failure) {
     $lines = explode("\n", $testcase->failure);
diff --git a/core/modules/system/tests/modules/apcu_hater_test/apcu_hater_test.info.yml b/core/modules/system/tests/modules/apcu_hater_test/apcu_hater_test.info.yml
new file mode 100644
index 0000000000..51659c0c94
--- /dev/null
+++ b/core/modules/system/tests/modules/apcu_hater_test/apcu_hater_test.info.yml
@@ -0,0 +1,6 @@
+name: 'APCu hater'
+type: module
+description: 'Support module for clear apcu cache'
+package: Testing
+version: VERSION
+core: 8.x
diff --git a/core/modules/system/tests/modules/apcu_hater_test/apcu_hater_test.routing.yml b/core/modules/system/tests/modules/apcu_hater_test/apcu_hater_test.routing.yml
new file mode 100644
index 0000000000..9d03409f89
--- /dev/null
+++ b/core/modules/system/tests/modules/apcu_hater_test/apcu_hater_test.routing.yml
@@ -0,0 +1,30 @@
+apcu_hater_test.clear_apcu_cache:
+  path: '/apcu-hater-test/clear-apcu-cache'
+  defaults:
+    _controller: '\Drupal\apcu_hater_test\Controller\ApcuClearCacheController::clearAllCache'
+  requirements:
+    _access: 'TRUE'
+apcu_hater_test.clear_apcu_cache_by_test:
+  path: '/apcu-hater-test/clear-apcu-cache-by-test/{prefix}'
+  defaults:
+    _controller: '\Drupal\apcu_hater_test\Controller\ApcuClearCacheController::clearAllCacheByTest'
+  requirements:
+    _access: 'TRUE'
+apcu_hater_test.drupal_clear_cache:
+  path: '/apcu-hater-test/drupal-clear-caches1'
+  defaults:
+    _controller: '\Drupal\apcu_hater_test\Controller\ApcuClearCacheController::drupalClearCache1'
+  requirements:
+    _access: 'TRUE'
+apcu_hater_test.drupal_clear_cache2:
+  path: '/apcu-hater-test/drupal-clear-caches2'
+  defaults:
+    _controller: '\Drupal\apcu_hater_test\Controller\ApcuClearCacheController::drupalClearCache2'
+  requirements:
+    _access: 'TRUE'
+apcu_hater_test.drupal_clear_cache3:
+  path: '/apcu-hater-test/drupal-clear-caches3'
+  defaults:
+    _controller: '\Drupal\apcu_hater_test\Controller\ApcuClearCacheController::drupalClearCache3'
+  requirements:
+    _access: 'TRUE'
diff --git a/core/modules/system/tests/modules/apcu_hater_test/src/Controller/ApcuClearCacheController.php b/core/modules/system/tests/modules/apcu_hater_test/src/Controller/ApcuClearCacheController.php
new file mode 100644
index 0000000000..7c4e860018
--- /dev/null
+++ b/core/modules/system/tests/modules/apcu_hater_test/src/Controller/ApcuClearCacheController.php
@@ -0,0 +1,62 @@
+<?php
+
+namespace Drupal\apcu_hater_test\Controller;
+
+use Drupal\Core\Cache\Cache;
+use Drupal\Core\Controller\ControllerBase;
+use Drupal\Core\PhpStorage\PhpStorageFactory;
+
+/**
+ * Controller routines for error_test routes.
+ */
+class ApcuClearCacheController extends ControllerBase {
+
+  public function clearAllCache() {
+    apcu_clear_cache();
+  }
+
+  public function clearAllCacheByTest($prefix) {
+    apcu_delete(new \APCUIterator('/' . $prefix . '/'));
+  }
+
+  public function drupalClearCache1() {
+    drupal_flush_all_caches();
+  }
+
+  public function drupalClearCache2() {
+    $module_handler = \Drupal::moduleHandler();
+    // Flush all persistent caches.
+    // This is executed based on old/previously known information, which is
+    // sufficient, since new extensions cannot have any primed caches yet.
+    $module_handler->invokeAll('cache_flush');
+    foreach (Cache::getBins() as $service_id => $cache_backend) {
+      $cache_backend->deleteAll();
+    }
+  }
+
+  public function drupalClearCache3() {
+    $module_handler = \Drupal::moduleHandler();
+    // Flush all persistent caches.
+    // This is executed based on old/previously known information, which is
+    // sufficient, since new extensions cannot have any primed caches yet.
+    $module_handler->invokeAll('cache_flush');
+    foreach (Cache::getBins() as $service_id => $cache_backend) {
+      $cache_backend->deleteAll();
+    }
+
+    // Flush asset file caches.
+    \Drupal::service('asset.css.collection_optimizer')->deleteAll();
+    \Drupal::service('asset.js.collection_optimizer')->deleteAll();
+    _drupal_flush_css_js();
+
+    // Reset all static caches.
+    drupal_static_reset();
+
+    // Invalidate the container.
+    \Drupal::service('kernel')->invalidateContainer();
+
+    // Wipe the Twig PHP Storage cache.
+    PhpStorageFactory::get('twig')->deleteAll();
+  }
+
+}
diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index ae33bb5410..274aa0cef2 100644
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -143,6 +143,9 @@
 
 $test_list = simpletest_script_get_test_list();
 
+if (!in_array('Drupal\Tests\aggregator\Functional\Update\AggregatorUpdateTest', $test_list)) {
+  $test_list = [];
+}
 // Try to allocate unlimited time to run the tests.
 drupal_set_time_limit(0);
 simpletest_script_reporter_init();
@@ -664,6 +667,9 @@ function simpletest_script_execute_batch($test_classes) {
   $total_status = SIMPLETEST_SCRIPT_EXIT_SUCCESS;
 
   // Multi-process execution.
+  $directory = PublicStream::basePath() . '/simpletest';
+  file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
+  $logfile = $directory . '/mem-child-proc.log';
   $children = array();
   while (!empty($test_classes) || !empty($children)) {
     while (count($children) < $args['concurrency']) {
@@ -693,6 +699,13 @@ function simpletest_script_execute_batch($test_classes) {
         exit(SIMPLETEST_SCRIPT_EXIT_SUCCESS);
       }
 
+      $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, gmdate('YmdHis') . ';+;' . $test_id . ';' . $test_class . ';' . $apcuinfo . PHP_EOL, FILE_APPEND | LOCK_EX);
+
       // Register our new child.
       $children[] = array(
         'process' => $process,
@@ -743,6 +756,13 @@ function simpletest_script_execute_batch($test_classes) {
           simpletest_script_cleanup($child['test_id'], $child['class'], $status['exitcode']);
         }
 
+        $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, gmdate('YmdHis') . ';-;' . $child['test_id'] . ';' . $child['class'] . ';' . $apcuinfo . PHP_EOL, FILE_APPEND | LOCK_EX);
+
         // Remove this child.
         unset($children[$cid]);
       }
@@ -806,6 +826,7 @@ function simpletest_script_run_one_test($test_id, $test_class) {
       $test->dieOnFail = (bool) $args['die-on-fail'];
       $test->verbose = (bool) $args['verbose'];
       $test->run($methods);
+      $test->results['#debug'] = memory_get_peak_usage(TRUE);
       simpletest_script_reporter_display_summary($test_class, $test->results);
 
       $status = SIMPLETEST_SCRIPT_EXIT_SUCCESS;
@@ -1186,7 +1207,7 @@ function simpletest_script_reporter_display_summary($class, $results) {
   // Output all test results vertically aligned.
   // Cut off the class name after 60 chars, and pad each group with 3 digits
   // by default (more than 999 assertions are rare).
-  $output = vsprintf('%-60.60s %10s %9s %14s %12s', array(
+  $output = vsprintf('%-80.80s %10s %9s %14s %12s', array(
     $class,
     $results['#pass'] . ' passes',
     !$results['#fail'] ? '' : $results['#fail'] . ' fails',
diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php
index 3260f6ea01..6724d47aae 100644
--- a/core/tests/Drupal/Tests/BrowserTestBase.php
+++ b/core/tests/Drupal/Tests/BrowserTestBase.php
@@ -14,6 +14,7 @@
 use Drupal\Core\Database\Database;
 use Drupal\Core\Session\AccountInterface;
 use Drupal\Core\Session\AnonymousUserSession;
+use Drupal\Core\Site\Settings;
 use Drupal\Core\Test\FunctionalTestSetupTrait;
 use Drupal\Core\Test\TestSetupTrait;
 use Drupal\Core\Url;
@@ -109,7 +110,7 @@
    *
    * @see \Drupal\Tests\BrowserTestBase::installDrupal()
    */
-  protected static $modules = [];
+  protected static $modules = ['apcu_hater_test'];
 
   /**
    * The profile to install as a basis for testing.
@@ -548,6 +549,8 @@ protected function cleanupEnvironment() {
    * {@inheritdoc}
    */
   protected function tearDown() {
+    $this->drupalGet('/apcu-hater-test/drupal-clear-caches1');
+
     parent::tearDown();
 
     // Destroy the testing kernel.
diff --git a/index.php b/index.php
index 750dc282dc..ed58d191f5 100644
--- a/index.php
+++ b/index.php
@@ -20,3 +20,11 @@
 $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); $more = apcu_cache_info(TRUE);
+  $apcuinfo = $info['avail_mem'].';'.$info['seg_size'].';'.$info['num_seg'].';'.$more['num_slots'].';'.$more['num_hits'].';'.$more['num_misses'].';'.$more['num_inserts'].';'.$more['num_entries'].';'.$more['expunges'];
+}
+file_put_contents($logfile, gmdate('YmdHis') . ';I;' . memory_get_peak_usage(TRUE) . ';' . $apcuinfo . PHP_EOL, FILE_APPEND | LOCK_EX);
diff --git a/update.php b/update.php
index 59e808ed24..3537972494 100644
--- a/update.php
+++ b/update.php
@@ -29,3 +29,11 @@
 $response->send();
 
 $kernel->terminate($request, $response);
+
+$logfile = $kernel->getAppRoot() . '/sites/default/files/simpletest/mem-update.log';
+$apcuinfo = ';;;;;;;;';
+if (function_exists('apcu_sma_info')) {
+  $info = apcu_sma_info(TRUE); $more = apcu_cache_info(TRUE);
+  $apcuinfo = $info['avail_mem'].';'.$info['seg_size'].';'.$info['num_seg'].';'.$more['num_slots'].';'.$more['num_hits'].';'.$more['num_misses'].';'.$more['num_inserts'].';'.$more['num_entries'].';'.$more['expunges'];
+}
+file_put_contents($logfile, gmdate('YmdHis') . ';U;' . memory_get_peak_usage(TRUE) . ';' . $apcuinfo . PHP_EOL, FILE_APPEND | LOCK_EX);
