diff --git a/core/lib/Drupal/Core/EventSubscriber/ExceptionTestSiteSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ExceptionTestSiteSubscriber.php
index d8f1a61..6e4f82d 100644
--- a/core/lib/Drupal/Core/EventSubscriber/ExceptionTestSiteSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/ExceptionTestSiteSubscriber.php
@@ -8,7 +8,9 @@
 namespace Drupal\Core\EventSubscriber;
 
 use Drupal\Core\Utility\Error;
+use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
 use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
+use Symfony\Component\HttpKernel\KernelEvents;
 
 /**
  * Custom handling of errors when in a system-under-test.
@@ -46,7 +48,7 @@ public function on500(GetResponseForExceptionEvent $event) {
 
     // When running inside the testing framework, we relay the errors
     // to the tested site by the way of HTTP headers.
-    if (DRUPAL_TEST_IN_CHILD_SITE && !headers_sent() && (!defined('SIMPLETEST_COLLECT_ERRORS') || SIMPLETEST_COLLECT_ERRORS)) {
+    if ($this->canAddHeaders()) {
       // $number does not use drupal_static as it should not be reset
       // as it uniquely identifies each PHP error.
       static $number = 0;
@@ -64,4 +66,41 @@ public function on500(GetResponseForExceptionEvent $event) {
     }
   }
 
+  /**
+   * Handles response being sent.
+   *
+   * @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event
+   *   The event to process.
+   */
+  public function onResponse(FilterResponseEvent $event) {
+    if ($this->canAddHeaders()) {
+      $response = $event->getResponse();
+      $memory_usage = memory_get_peak_usage(TRUE);
+      $response->headers->add([
+        'X-Drupal-Memory-Peak' => round($memory_usage / 1024 / 1024, 2),
+      ]);
+      $event->setResponse($response);
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function getSubscribedEvents() {
+    $events = parent::getSubscribedEvents();
+    // Add a listener for outputting peak memory usage.
+    $events[KernelEvents::RESPONSE][] = ['onResponse', 100];
+    return $events;
+  }
+
+  /**
+   * Returns if headers should be added.
+   *
+   * @return bool
+   *   TRUE if headers should be added.
+   */
+  protected function canAddHeaders() {
+    return (DRUPAL_TEST_IN_CHILD_SITE && !headers_sent() && (!defined('SIMPLETEST_COLLECT_ERRORS') || SIMPLETEST_COLLECT_ERRORS));
+  }
+
 }
diff --git a/core/modules/simpletest/src/Tests/BrokenSetUpTest.php b/core/modules/simpletest/src/Tests/BrokenSetUpTest.php
index 6621545..dae351b 100644
--- a/core/modules/simpletest/src/Tests/BrokenSetUpTest.php
+++ b/core/modules/simpletest/src/Tests/BrokenSetUpTest.php
@@ -30,6 +30,11 @@ class BrokenSetUpTest extends WebTestBase {
   public static $modules = array('simpletest');
 
   /**
+   * The memory limit for this test, Testing module requires 128M.
+   */
+  protected $memoryUsageTrigger = 128;
+
+  /**
    * The path to the shared trigger file.
    *
    * @var string
diff --git a/core/modules/simpletest/src/Tests/InstallationProfileModuleTestsTest.php b/core/modules/simpletest/src/Tests/InstallationProfileModuleTestsTest.php
index 424469a..4cca66a 100644
--- a/core/modules/simpletest/src/Tests/InstallationProfileModuleTestsTest.php
+++ b/core/modules/simpletest/src/Tests/InstallationProfileModuleTestsTest.php
@@ -31,6 +31,11 @@ class InstallationProfileModuleTestsTest extends WebTestBase {
   protected $adminUser;
 
   /**
+   * The memory limit for this test, Testing module requires 128M.
+   */
+  protected $memoryUsageTrigger = 128;
+
+  /**
    * Use the Testing profile.
    *
    * The Testing profile contains drupal_system_listing_compatible_test.test,
diff --git a/core/modules/simpletest/src/Tests/MissingCheckedRequirementsTest.php b/core/modules/simpletest/src/Tests/MissingCheckedRequirementsTest.php
index e4790f9..667181e 100644
--- a/core/modules/simpletest/src/Tests/MissingCheckedRequirementsTest.php
+++ b/core/modules/simpletest/src/Tests/MissingCheckedRequirementsTest.php
@@ -23,6 +23,11 @@ class MissingCheckedRequirementsTest extends WebTestBase {
    */
   public static $modules = array('simpletest');
 
+  /**
+   * The memory limit for this test, Testing module requires 128M.
+   */
+  protected $memoryUsageTrigger = 128;
+
   protected function setUp() {
     parent::setUp();
     $admin_user = $this->drupalCreateUser(array('administer unit tests'));
diff --git a/core/modules/simpletest/src/Tests/OtherInstallationProfileTestsTest.php b/core/modules/simpletest/src/Tests/OtherInstallationProfileTestsTest.php
index 9cfbfff..74ce9f2 100644
--- a/core/modules/simpletest/src/Tests/OtherInstallationProfileTestsTest.php
+++ b/core/modules/simpletest/src/Tests/OtherInstallationProfileTestsTest.php
@@ -39,6 +39,11 @@ class OtherInstallationProfileTestsTest extends WebTestBase {
   protected $profile = 'minimal';
 
   /**
+   * The memory limit for this test, Testing module requires 128M.
+   */
+  protected $memoryUsageTrigger = 128;
+
+  /**
    * An administrative user with permission to administer unit tests.
    *
    * @var \Drupal\user\UserInterface
diff --git a/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php b/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php
index 956d677..cfd7bc4 100644
--- a/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php
+++ b/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php
@@ -24,6 +24,11 @@ class SimpleTestBrowserTest extends WebTestBase {
    */
   public static $modules = array('simpletest', 'test_page_test');
 
+  /**
+   * The memory limit for this test, Testing module requires 128M.
+   */
+  protected $memoryUsageTrigger = 128;
+
   public function setUp() {
     parent::setUp();
     // Create and log in an admin user.
diff --git a/core/modules/simpletest/src/Tests/SimpleTestTest.php b/core/modules/simpletest/src/Tests/SimpleTestTest.php
index 2514d9d..fc4e865 100644
--- a/core/modules/simpletest/src/Tests/SimpleTestTest.php
+++ b/core/modules/simpletest/src/Tests/SimpleTestTest.php
@@ -27,6 +27,11 @@ class SimpleTestTest extends WebTestBase {
   public static $modules = array('simpletest', 'test_page_test');
 
   /**
+   * The memory limit for this test, Testing module requires 128M.
+   */
+  protected $memoryUsageTrigger = 128;
+
+  /**
    * The results array that has been parsed by getTestResults().
    *
    * @var array
diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php
index 3affb15..9c64c20 100644
--- a/core/modules/simpletest/src/WebTestBase.php
+++ b/core/modules/simpletest/src/WebTestBase.php
@@ -62,6 +62,13 @@
   protected $url;
 
   /**
+   * Set to the maximum number of MB of memory usage to allow on the child site.
+   *
+   * @var int
+   */
+  protected $memoryUsageTrigger = 64;
+
+  /**
    * The handle of the current cURL connection.
    *
    * @var resource
@@ -1399,6 +1406,15 @@ protected function curlHeaderCallback($curlHandler, $header) {
       // the header.
       call_user_func_array(array(&$this, 'error'), unserialize(urldecode($matches[1])));
     }
+    if (preg_match('/^X-Drupal-Memory-Peak: (.*)$/', $header, $matches)) {
+      if ((float) $matches[1] >= $this->memoryUsageTrigger) {
+        $this->fail(SafeMarkup::format('Child site memory usage (@siteMB) exceeded acceptable maximum (@maxMB) on url @url', [
+          '@url' => $this->getUrl(),
+          '@site' => $matches[1],
+          '@max' => $this->memoryUsageTrigger,
+        ]));
+      }
+    }
 
     // Save cookies.
     if (preg_match('/^Set-Cookie: ([^=]+)=(.+)/', $header, $matches)) {
