So the question is: how do I trace the program execution, or how do I reorder the #include statements, or how do I put padding or a marker or harmless instructions on the stack so I can identify which library or which included class function or which code is failing to clean up the stack?

I request no comments from PaulS. Your comments are demoralizing, so do not offer your comments. Thanks.

The Arduino is a great community, fun platform and Open Source. Thanks again.

The sketch I am developing is a data logger that reads barometeric pressure.The Arduino is a Uno, and stacked on the Uno is the Adafruit logger plus real time clock.The gadget is running now, logging barometeric pressure.When compiled, the program reports:

The compiler message doesn't seem to say I am running out of memory. What is your comment, is 7280 bytes not enough?

Trying to learn more about the memory used, I switched on compile messages in the Arduino preferences.The compile and upload messages tell a lot. I removed some unused variables and cleared away some compiler warnings.

So I pause here and ask you a question, can you show me a code example of printing out the address of a string variable? is there any way I can create a couple of pointers that will tell me the exact memory addressof some of my data values? Are there any system memory variables that I can read? Can you show me any way to read the memory value when a function() has run and show me the instruction pointer or memory address right before the return; statement?

It looks like the avr-gcc library has a library and a function call, but I'd need a tutorial example to learn how to use it.

What I am trying to add is an LCD display. So far the display works and I have a pinout.

So for simplification, I leave the LCD disconnected and I uncomment the LCD library code one line at a time . The software problem that gets me is the command that opens the SD card for writing always failswhen I uncomment the LCD library initialization instruction like this:

If I am out of memory well how do I print out the memory addresses of the last data items?

First, you have to know which are the last data items. This means that you need a memory map, and you have to know where the stack and the heap are.

The biggest problem with memory usage on the Arduino is that the static memory stuff occupies one end of the memory. The heap is next to that, and grows and shrinks as dynamic memory allocation occurs. The stack starts at the other end, and grows and shrinks as functions are called and returns happen. As long as the heap and the stack never meet, no problem. Once they do, all bets are off.

There are ways of determining how far the edge of the heap and the top of the stack are from each other. But, the values changes as you try to measure them.

Thanks for the code example for displaying the address of a data value.

I bought a Arduino Due with 16x more memory than the Arduino Uno and tried my program with so called "library stack problems" on the DUE.

The effort introduced a lot more uncertainties but the bottom line is the SD.open() function call consistently works when running a demo program and consistently fails when running with a several libraries.

Lack of program memory is not the single problem causing my application failure.

Here is the attack I am going to try:

I am going to isolate the SD library activity, the RTC (real time clock) activity, and the String() activity each into a separate function(). For the resulting function() calls, I am going to put "address of..." telltale number data at the top and the bottom of each function().Then I have separated the function() s so they do not fight and I can see of one of them is failing to return with the stack in good order.