Small Arduino code consumes high ram usage in VSCode compilation

As the image shown that a small Arduino test code (board config: Mega2560) consumes a large flash (10%) and ram (51%) usage after compilation, is there anything I missed? Thanks in advance for any hints.

Here is the code
testRotary.ino:

#include <a.h>

void setup()
{
    int a = 0;
}

void loop()
{
    int b = 1;
}

and a.h is just an empty file existed in somewhere that the path Arduino can include as libraries.

Here is the reply of compilation:

[Starting] Verifying sketch 'sketches\testRotaryText\testRotary.ino'

Please see the build logs in output path: d:\OneDrive\Projects\TrainDetectAlarm\build

Loading configuration...

Initializing packages...

Preparing boards...

Verifying...

Sketch uses 26984 bytes (10%) of program storage space. Maximum is 253952 bytes.

Global variables use 4208 bytes (51%) of dynamic memory, leaving 3984 bytes for local variables. Maximum is 8192 bytes.

IntelliSense auto-configuration disabled.

[Done] Verifying sketch 'sketches\testRotaryText\testRotary.ino'


What happens if you don’t include a.h ? What’s in there ?

Side note:
Please never post a picture of text again. Just post text using code tags (for the code and compiler message ). please read How to get the best out of this forum

the reply is normal if no include a.h:

Sketch uses 662 bytes (0%) of program storage space. Maximum is 253952 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 8183 bytes for local variables. Maximum is 8192 bytes.

What else is in that TdaUI directory?

Well then the answer is in what you did not share… may be you have other ino files, may be some code that loads anyway or whatever…. Share details

Is a a true library or is it in the same directory as your .ino file?
You could try
#include "a.h"
There might be somewhere in the search path another a.h....
Maybe such a short name is not a good idea...

@joneschung
Why did you decide that the code is small? Everything that is in the file included by the #include directive is also a part of the code. Maybe you have 10 thousand lines of code there - that's how the size of the firmware turns out

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.