arduino reset when instantiating an object


I'm experiencing an strange reset problem.

It seems that arduino resets when I do

  struct zigbee a;
  XBee xbee(a);

The XBee class and the struct zigbee forms part of an XBee library I'm developing.

The XBee class has a bunch of functions but I'm not calling any of those functions(I commented out all calls to xbee.xxxx() in the sketch).

The strange thing is that this reset doesn't seem to be related with any code running on XBee constructor neither, because I commented out all statements inside the constructor and the reset keeps ocurring. The reset always comes when instantiating the object. The funny part is that if I remove/change the a string literal from "12345678" to "1234567" on the XBee class then it doesn't reset anymore. But that code that I'm changing it's never executed!!. I never call that code

So I'm wondering if it could be a linking error or something like that.

My real question is how to I debug such an error? Do I need to buy an JTAG debugger, (AVR Dragon?) or is there any way to spot the problem usign avr-objdump?

What could I do to find out what's happening?

Sounds like typical out of RAM behavior.


I'm pretty new at this so it didn't occur to me that arduino has a pretty limited amount of RAM. It seems that this could be the cause indeed. I'm using a lot of Serial.print("debug statements") and as I read on this literals take ram space as well.

Thank you very much, from now on I will keep an eye on the RAM usage.

You can put the string constants in program memory (flash). This page has some examples: