Memory overflow by using C++ operator ''new''
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2013-04-14 1:06 PM
Posted on April 14, 2013 at 22:06
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?
This discussion is locked. Please start a new topic to ask your question.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2013-06-14 1:13 PM
Posted on June 14, 2013 at 22:13
I found a solution for this problem.
the ''--specs=nano.specs'' argument has to be passed to the linker to enable newlib-nano. The memory overhead for the new operator is less than 800 Bytes. Tested with GNU ARM 4.7 Hope it can helps someone