Difference between revisions of "How to use SystemView Heap Monitoring - Custom Heap"
Line 1: | Line 1: | ||
This article assumes a working SystemView setup. To gain some more info on this subject, please consult either the main article ([[How to use SystemView Heap_Monitoring]]) or the SystemView documentation. |
This article assumes a working SystemView setup. To gain some more info on this subject, please consult either the main article ([[How to use SystemView Heap_Monitoring]]) or the SystemView documentation. |
||
+ | |||
<pre> |
<pre> |
||
static void* _MyMalloc(size_t size) { |
static void* _MyMalloc(size_t size) { |
||
void* p = malloc(size); |
void* p = malloc(size); |
||
− | // SystemView needs the real internal heap block size, not the amount requested by the user |
+ | // SystemView needs the real internal heap block size, not the amount requested by the user |
− | // hence the call to a helper function _GetAllocBlockSize for the currently selected heap type ('Basic') |
||
SEGGER_SYSVIEW_HeapAlloc(__heap_start__, p, _GetAllocBlockSize(size)); |
SEGGER_SYSVIEW_HeapAlloc(__heap_start__, p, _GetAllocBlockSize(size)); |
||
return p; |
return p; |
||
Line 12: | Line 12: | ||
void* rp = realloc(p, size); |
void* rp = realloc(p, size); |
||
SEGGER_SYSVIEW_HeapFree(__heap_start__, p); |
SEGGER_SYSVIEW_HeapFree(__heap_start__, p); |
||
− | // SystemView needs the real internal heap block size, not the amount requested by the user |
+ | // SystemView needs the real internal heap block size, not the amount requested by the user |
− | // hence the call to a helper function _GetAllocBlockSize for the currently selected heap type ('Basic') |
||
SEGGER_SYSVIEW_HeapAlloc(__heap_start__, rp, _GetAllocBlockSize(size)); |
SEGGER_SYSVIEW_HeapAlloc(__heap_start__, rp, _GetAllocBlockSize(size)); |
||
return rp; |
return rp; |
Revision as of 17:28, 18 July 2023
This article assumes a working SystemView setup. To gain some more info on this subject, please consult either the main article (How to use SystemView Heap_Monitoring) or the SystemView documentation.
static void* _MyMalloc(size_t size) { void* p = malloc(size); // SystemView needs the real internal heap block size, not the amount requested by the user SEGGER_SYSVIEW_HeapAlloc(__heap_start__, p, _GetAllocBlockSize(size)); return p; } static void* _MyRealloc(void* p, size_t size) { void* rp = realloc(p, size); SEGGER_SYSVIEW_HeapFree(__heap_start__, p); // SystemView needs the real internal heap block size, not the amount requested by the user SEGGER_SYSVIEW_HeapAlloc(__heap_start__, rp, _GetAllocBlockSize(size)); return rp; } static void _MyFree(void* p) { free(p); SEGGER_SYSVIEW_HeapFree(__heap_start__, p); }