Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4878

General • Re: Free Memory (using C SDK).

$
0
0
From where getTotalHeap and getFreeHeap come?

What works is malloc_stats(), it prints directly:
max system bytes = 43896
system bytes = 43896
in use bytes = 40008

Also the following structure from malloc.h:

Code:

/* This version of struct mallinfo must match the one in   libc/stdlib/mallocr.c.  */struct mallinfo {  size_t arena;    /* total space allocated from system */  size_t ordblks;  /* number of non-inuse chunks */  size_t smblks;   /* unused -- always zero */  size_t hblks;    /* number of mmapped regions */  size_t hblkhd;   /* total space in mmapped regions */  size_t usmblks;  /* unused -- always zero */  size_t fsmblks;  /* unused -- always zero */  size_t uordblks; /* total allocated space */  size_t fordblks; /* total non-inuse space */  size_t keepcost; /* top-most, releasable (via malloc_trim) space */};
All of these are showing only to the used heap, including fragments.
Probably the rest can be safely assumed/calculated from linker info, without forcing malloc.
Usually, the stacks stay bounded in the other SRAM banks (SCRATCH).

Statistics: Posted by gmx — Sat Nov 02, 2024 4:35 pm



Viewing all articles
Browse latest Browse all 4878

Trending Articles