AnsweredAssumed Answered

Memory overflow by using C++ operator "new"

Question asked by navarro.benjamin.001 on Apr 14, 2013
Latest reply on Jun 14, 2013 by navarro.benjamin.001
Hi everyone

I use STMF1 and STMF4 devices for some time now but I just started with STM32F0 devices (Discovery board) and I have a quite strange problem.

I created a class called Pin that can initialize any GPIO pin and use it (read, on, off, toggle, etc). When I create an instance of it like this :

Pin LED(GPIOC, GPIO_Pin_8);

everything is okay, but if I do this :

Pin* LED;
...
LED = new Pin(GPIOC, GPIO_Pin_8);

I have a flash memory overflow of 30492 bytes.

When I'm invoking the size command before and after creating an instance of Pin with the first method I have this :

Invoking: ARM Sourcery Mac OS X GNU Print Size
arm-none-eabi-size  --format=berkeley base.elf
   text       data        bss        dec        hex    filename
   4356       2132       1128       7616       1dc0    base.elf

Invoking: ARM Sourcery Mac OS X GNU Print Size
arm-none-eabi-size  --format=berkeley base.elf
   text       data        bss        dec        hex    filename
   4380       2132       1128       7640       1dd8    base.elf


Nothing extraordinary and I have still plenty of free space.

I'm using Eclipse with the GCC ARM toolchain on Mac OS X.

Does anyone have an idea about the origin of this problem?

Outcomes