Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print_binary.cpp is linked/included unintentionally and bloats program #43

Open
joshgoebel opened this issue Mar 30, 2014 · 3 comments
Open

Comments

@joshgoebel
Copy link

Anytime ANY file in hb_utilities is referenced the entire folder gets compiled and linked. The linker is pretty good about throwing out what isn't used but I think because eventSerial is referenced in the main.cpp (internal to Arduino) that somehow the Serial stuff sticks in a bad way.

My code:

#include <click_counter.h>

Building:

Global variables use 195 bytes (19%) of dynamic memory,

With that line commented:

Global variables use 22 bytes (2%) of dynamic memory,

Note, I'm not even actually using any click_counter code in this example... the whole difference you are seeing is the extra Serial variable space that's getting added.

I'm not sure of anyway to fix this without putting each of the libraries into separate folders instead of having them all in the same folder. At the very least print_binary should be split off. I can do this and submit a pull request I just wasn't sure what direction I should go with fixing this. Or maybe you have a better idea?

I'm using Arduino 1.5.x but I'd guess the older IDE might exhibit the same behavior.

@dhiltonp
Copy link
Owner

This memory issue is something I've not seen, as I only see memory usage at run time via DEBUG_* (using Serial).

I'd expect the problem to occurs with 1.0.5 as well, as I'd be surprised if Arduino 1.5 is using a significantly newer version of avr-gcc on the backend.

Simply moving all hb_utilities that use Serial to a separate directory would fix it (this is a bit of a kludge).

@joshgoebel
Copy link
Author

My first thought was to slap #ifdef DEBUG around the calls but then I saw the only place that file is used is by one of the test programs... could we just say that serial only works in debug mode and require the test program to define DEBUG?

@dhiltonp
Copy link
Owner

That would be great, but I think you'll hit a little issue with the #defines... it's the same cause for the BUILD_HACK.

Please try it; maybe you'll see a solution I've missed :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants