Skip to content

Commit 859fe97

Browse files
[nrf noup] [zephyr] Add config to enable watermarks support
Added a config to control enabling support for heap watermarks within the Zephyr platform.
1 parent d1a9faf commit 859fe97

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

config/zephyr/Kconfig

+6
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,12 @@ config CHIP_MALLOC_SYS_HEAP_SIZE
417417
the heap used by the memory allocation functions based on sys_heap from
418418
Zephyr RTOS.
419419

420+
config CHIP_MALLOC_SYS_HEAP_WATERMARKS_SUPPORT
421+
bool "Enable support for heap watermarks based on Zephyr sys_heap"
422+
help
423+
Enables support for getting current heap high watermark and resetting
424+
watermarks.
425+
420426
endif
421427

422428
module = MATTER

src/platform/Zephyr/DiagnosticDataProviderImpl.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ DiagnosticDataProviderImpl::DiagnosticDataProviderImpl() : mBootReason(Determine
123123

124124
bool DiagnosticDataProviderImpl::SupportsWatermarks()
125125
{
126-
#ifdef CONFIG_CHIP_MALLOC_SYS_HEAP
126+
#ifdef CONFIG_CHIP_MALLOC_SYS_HEAP && CHIP_MALLOC_SYS_HEAP_WATERMARKS_SUPPORT
127127
return true;
128128
#else
129129
return false;
@@ -165,7 +165,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapUsed(uint64_t & currentHeap
165165

166166
CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapHighWatermark(uint64_t & currentHeapHighWatermark)
167167
{
168-
#ifdef CONFIG_CHIP_MALLOC_SYS_HEAP
168+
#ifdef CONFIG_CHIP_MALLOC_SYS_HEAP && CHIP_MALLOC_SYS_HEAP_WATERMARKS_SUPPORT
169169
Malloc::Stats stats;
170170
ReturnErrorOnFailure(Malloc::GetStats(stats));
171171

@@ -178,7 +178,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapHighWatermark(uint64_t & cu
178178

179179
CHIP_ERROR DiagnosticDataProviderImpl::ResetWatermarks()
180180
{
181-
#ifdef CONFIG_CHIP_MALLOC_SYS_HEAP
181+
#ifdef CONFIG_CHIP_MALLOC_SYS_HEAP && CHIP_MALLOC_SYS_HEAP_WATERMARKS_SUPPORT
182182
Malloc::ResetMaxStats();
183183
return CHIP_NO_ERROR;
184184
#else

0 commit comments

Comments
 (0)