Bridge Process Console.print, Strings disapear

I have a sketch that's consuming 88% of the storage. Its printing some values to Console to debug it and after some time it stops to print the values. Does somebody have a clue why the values disapear?

This is how the part looks like:

void writeFile(String filename, String content){
  String fileURL = "/tmp/sensors/test";
  String commandString = "echo "; 
  commandString += content; 
  commandString += " > ";
  commandString += fileURL;
  commandString += filename;
  Console.print("commandString:");Console.println(commandString);
  Console.print("filename:");Console.println(filename);
  Console.print("content:");Console.println(content);
  Console.print("fileURL:");Console.println(fileURL);
  Console.print("filename:");Console.println(filename);
  Process p;
    p.runShellCommand(commandString);
    delay(100);
    p.close();
  delay(2000);
}

This is one part of the Console output:

20:49:58.458 -> commandString:
20:49:58.458 -> filename:
20:49:58.458 -> content:
20:49:58.458 -> fileURL:
20:49:58.458 -> filename:

i can't post the full code because it exceeds the 9000 character max per post. You can have a look here.

In reading a book on Python, I discovered a new word, immutable. It means something cannot be changed and it applies to "String". A string in any computer language I know of, a String cannot be changed. That includes C++ for the Arduino. What appears to you the happening is the String is really changed. But in reality a NEW string is created with the change or addition you coded. The old String is still in memory, and will never be reclaimed. So every time you do something with a String, you are using more memory.

Use "string" instead.

PAul

C++ String is not immutable because there's no check if it is or it is not.
You can have:

String s = "Hello";
//s is Hello
s[0] = 'M';
s is now Mello

arduino_new:
C++ String is not immutable because there's no check if it is or it is not.
You can have:

String s = "Hello";

//s is Hello
s[0] = 'M';
s is now Mello

That is identical to creating a NEW string.

Paul

Paul_KD7HB:
That is identical to creating a NEW string.

Paul

I'm sure that it is not.

From arduino String source code:

char & String::operator[]( unsigned int index )
{
  static char dummy_writable_char;
  if (index >= _length || !_buffer) {
    dummy_writable_char = 0;
    return dummy_writable_char;
  }
  return _buffer[ index ];
}