Skip to content

Inconsistent heap sizes between toolchains, especially IAR #3466

Closed
@kuggenhoffen

Description

@kuggenhoffen

Description

  • Type: Bug
  • Priority: Major

Bug

Target
K64F

Toolchain:
IAR

Toolchain version:
7.80.2.11975

mbed-cli version:
1.0.0

meed-os sha:
a1c0840 (HEAD, tag: mbed_lib_rev129, tag: mbed-os-5.2.2) Merge pull request #3227 from ARMmbed/release-candidate

Expected behavior
I would expect available heap amount to be somewhat similar between all the toolchains to guarantee compatibility. Currently it seems that the available heap is very different in IAR (~65k) compared to ARMCC (~180k) or GCC (~175k)

Actual behavior
IAR heap size seems to be fixed at ~65k

Steps to reproduce
Numbers above were determined with following code on K64F with serial terminal:

#include "mbed.h"

RawSerial   pc(USBTX, USBRX);

static void heap_loop_check(int maxSize, int total)
{
    pc.printf("Next try: %d, total so far: %d\r\n", maxSize, total);
    for(int n = maxSize; n >= 0; n--){
        if(n == 0){
            pc.printf("Available heap: %d\r\n", total);
            break;
        }
        void *block;
        block = malloc(n);
        if (!block) {
          continue;
        }
        heap_loop_check(n, total + n);
        free(block);
        break;
    }
}

int main() {
    pc.baud(115200);
    heap_loop_check(80000, 0);
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions