This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/AM3358: C function for available memory

Genius 5820 points
Part Number: AM3358


Tool/software: TI C/C++ Compiler

Hi,

I'm aware of the fact that "normal" ANSI-C provides memory functions like malloc() or free () but not a function to check how much memory is still available for usage. As for an embedded platform the situation is somewhat different (fixed memory layout based on linker command file), my question: is there a function available which tells me, how much memory is still available for allocation with malloc()?

Thanks!

  • To clarify this: I'm talking about the TI-compiler used for bare metal programming, so no Linux or RTOS or something else is involved!

  • I presume you use the TI ARM compiler.  Starting with version 18.12.x.LTS, these two non-standard functions are available and declared in stdlib.h ...

    size_t __TI_heap_total_available(void);
    size_t __TI_heap_largest_available(void);
    

    The first one returns the total number of bytes available, which may be fragmented.  The second one returns the largest allocation request that is available.

    Thanks and regards,

    -George