Fix and test heap allocation of PacketBuffers (#4632)

* Fix and test heap allocation of PacketBuffers

#### Problem

CHIP has to option to use heap-allocated packet buffers
(with `CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE == 0`) but
this configuration has been neglected, and CHIP neither builds
nor runs in this configuration.

#### Summary of Changes

Build fixes:

- Default `CHIP_CONFIG_RMP_RETRANS_TABLE_SIZE` to 15 for heap case.
    15 is the default packet buffer pool size in SystemConfig.h.
    See also issue #4335 - Our definition of the CRMP retransmission
    table size does not really make sense

Runtime fixes:

- Ensure echo server has enough buffer space for the response (and added
  `CHECK_RETURN_VALUE` to `EnsureReservedSize()`).
- Added room for MAC in echo requester.
- Added room for MAC in `chipSendUnicast()`.
- Added parameters to `CloneData()` to request header and trailing
  space.
- Fixed CHIPMem initialization for some tests.
- Fix tests that didn't allocate enough space.

Build and code changes to assist memory troubleshooting (these should have
no cost unless enabled):

- Added a build flag `chip_config_memory_debug_checks` and corresponding
  preprocessor definition `CHIP_CONFIG_MEMORY_DEBUG_CHECKS` to enable extra
  memory checks, at a performance cost. In particular, new functions
  `Platform::MemoryDebugCheckPointer()` and `PacketBufferHandle::Check()`
  operate when this is enabled.
- Added a build flag `chip_config_memory_debug_dmalloc` and corresponding
  preprocessor definition `CHIP_CONFIG_MEMORY_DEBUG_DMALLOC` to use the
  dmalloc debugging malloc library.
- Clarified conditions for the four configurations of PacketBuffer allocation.
- Replaced some PacketBuffer #define constants with scoped constexprs.
- Renamed `CHIP_SYSTEM_CONFIG_PACKETBUFFER_MAXALLOC` to
  `CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE` to remove the ambiguity of
  what a ‘maximum allocation’ is.

Build and automated test changes:

- Made standalone builds default to heap allocation.
- Run a set of unit tests with dmalloc.

fixes #4395 - Heap packet buffer allocation is broken
fixes #4390 - ReliableMessageProtocol assumes a buffer pool

* review

* review 2

* fix messaging shutdown

* review 3

* fix tests

Co-authored-by: Justin Wood <woody@apple.com>
diff --git a/src/messaging/ExchangeMgr.cpp b/src/messaging/ExchangeMgr.cpp
index 005eeb6..76bd6dc 100644
--- a/src/messaging/ExchangeMgr.cpp
+++ b/src/messaging/ExchangeMgr.cpp
@@ -1,6 +1,6 @@
 /*
  *
- *    Copyright (c) 2020 Project CHIP Authors
+ *    Copyright (c) 2020-2021 Project CHIP Authors
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -89,6 +89,8 @@
 
 CHIP_ERROR ExchangeManager::Shutdown()
 {
+    mReliableMessageMgr.Shutdown();
+
     if (mSessionMgr != nullptr)
     {
         mSessionMgr->SetDelegate(nullptr);