RAM issues with Ethernet + IRC protocol


First post and probably in the wrong section, so please don't chop my head off.
I was working as a support tech at DreamHack this weekend and i thought i'd make a tiny IRC bot that beep'ed a 15watt horn everytime someone sad "Hellooooo" in the DH chat.

At first i didn't know what whent wrong, the Arduino Duemilanove ATmega/328 card just kept rebooting or it just hung up on me.

I've got tons of debug lines that i'll probably don't need later on but for some reason the memory gets full right away when i start recieving characters from the IRC server.


I litterly have no idea what takes up 1000byte or RAM in just a few seconds, from what i can tell it's not "row" and it couldn't be "c" either.

PS: Sorry for a messy code, i just came from Python and well been trying to learn C++ for a while and this was a fun way to learn it :slight_smile:

Edit: here's an example output of what i get.

Note that from the beginning i have about 943 bytes of RAM when everything is initialized and i've connected.

Every serial.print or any string is located in Ram, so thats where your problem is.

I'm aware that if i store a string in a variable it takes up space and quite a lot, that's why i write over the string instead of creating new ones, shouldn't that help?
Otherwise, would Serial.flush(); do any good (if i needed the serial output which i don't)

Didn't know Serial.print stored each output in a new memory allocation but i get the same result when i remove anything that has to do with the Serial output.

Line 109:

            String row = String(520);

What's this local variable for? It goes out of scope before being used again.

Same question about line 35.

would Serial.flush(); do any good

Serial.flush() dumps any unread data in the buffer. It does not change the size of the buffer. So, no, it would not do any good.

your function int inStr(String find, String in) could be replaced by IndexOf See: indexOf() - Arduino Reference

What's this local variable for? It goes out of scope before being used again.

My bad, bad habbit from Python where that would replace the original global variable and thus removing anything in memory with that previous variable name. Sort of delete/renew principle. Replaced that and removed every Serial.print function and replaced the debug with some LED indicators instead and i can connect 50% of the time, write a few lines in the IRC channel that i join but i still end up with a non-responsive arduino :confused:

int inStr(String find, String in)

Must have misread that function, thought it only took a character at a time and returned the position in the string which was useless to me but yea, that could replace my inStr function and probably save me some space :slight_smile: