I am new in this forum, this my first posting and I am not native English. Please do let me know if something in my posting is against the communciation rules in this forum.

I am stuck in a problem with a larger project. Its about a Midi Controller and so far everything I have programmed works very well. Now I simply needed to add another String variable array (which I use as containers for LCD content and that works perfect so far) but when I only add that variable declaration my Mega 2560 will stop execution. Compilation is ok and Arduino V0022 reports 'Done Uploading' but then it will hang. Here is the code section with the variable declaration that includes the one variable that makes the difference. Its only declarations:

Glad you asked this, I had a similar problem, not hangs but all kinds of weird and unexplained behavior. I was going to post an inquiry but never did. Instead, I got rid of the string stuff and used functions like strcpy, strcat, itoa, etc., and all is well now. Maybe not quite as elegant but really not a whole lot more work or anything.

So not an answer for you, but you may not be alone and I'll be interested in other replies on this topic!

MikMo

Sketch size is the amount of Flash memory your program uses, your strings and other variables are stored in your Arduinos (very limited) RAM memory.The size of the RAM depends on which Arduino board you use. To rubb salt in the wound the RAM is alo used by some internal memory structures that Arduino uses when running your sketch. You use the RAM from one end, Arduino uses it from the other, if you use so much that you eat into the RAm Arduino uses for internal purposes unpredictable things will happen, usually in the shape of a crash / unresponsive system.

Try to allocate smaller arrays / strings and see if it works. If your program does not use all the Flash memory you can store some of your strings there. Check PROGMEM in the reference. Just remember only string constants can be stored that way, nothing that changes can be put there.

many thanks for fast and informative response, thats great !! Is there any information available about how much RAM is actually being used by String variables? I mean, I have defined quite some String arrays in my code but I have no idea how much memory that will allocate.

Counting the total number of characters in these Strings it isn't much at all considering that other people use the Arduino String Class for longer texts such as EMails. That is what is strange to me.

When I for example define:

String SBtnTrigger[131]; //0-127 is for values, 128-130 are filled in Setup

Hi everyone,I found the MemoryFree library and by using this function I could answer my own question:

By adding String variable arrays in different size and checking the free memory at some places in the code I found out, that a String variable per default (=empty) uses 10 bytes of memory. Thus, an array like this one will occupy 1000 bytes of memory:

String MyString[100];

I could trace the error in my program and it became clear, that adding the String Array in a size of > [10] simply killed my remaining memory.