cancel
Showing results for 
Search instead for 
Did you mean: 

Why does dynamic allocation make my program so big?

mhelyar
Associate

Before you say it, I know dynamic allocation is usually a bad idea with embedded software, this is more of a technical question.

If I create a new blank C++ project based on my Nucleo-L152RE in SW4STM32, the "text" portion of my compiled project read by the "size" command is about 1kB. If I then add the lines:

	int* p = new int;
	delete p;

text size becomes 75kB. data and BSS are basically unaffected.

Why is it so?

3 REPLIES 3

.text is code, so it's the libraries pulled in. Look at the mapfile.

JW

Bob S
Principal

Perhaps new pulls in exception handling code? As Jan said, check the map file.

and frankly pulling in anything the constructors/destructors touch or are dependent on

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..