feat(heap): add option to enable/disable heap trace function

This commit is contained in:
Dong Heng
2019-11-06 11:36:47 +08:00
parent fa4b8c5586
commit 975a7fd12a
6 changed files with 40 additions and 5 deletions

View File

@@ -32,7 +32,9 @@ extern heap_region_t g_heap_region[];
static const char *TAG = "heap_init";
size_t g_heap_region_num;
#ifdef CONFIG_HEAP_TRACING
int __g_heap_trace_mode = HEAP_TRACE_NONE;
#endif
/**
* @brief Initialize regions of memory to the collection of heaps at runtime.
@@ -116,7 +118,9 @@ void IRAM_ATTR *_heap_caps_malloc(size_t size, uint32_t caps, const char *file,
_heap_caps_lock(num);
#ifdef CONFIG_HEAP_TRACING
trace = __g_heap_trace_mode == HEAP_TRACE_LEAKS;
#endif
mem_blk_size = ptr2memblk_size(size, trace);

View File

@@ -12,6 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "sdkconfig.h"
#ifdef CONFIG_HEAP_TRACING
#include <string.h>
#include "esp_heap_caps.h"
@@ -146,3 +150,5 @@ void heap_trace_dump(void)
_heap_caps_unlock(num);
}
}
#endif /* CONFIG_HEAP_TRACING */