Serial read buffer

Hello,
I have written class to read data from serial but I noticed that its hanging from time to time - and its not releasing memory after read. I know using Strings is BAAD - but can some one tell me why this code is changing when lot of data come ?

#include "SerialReader.h"

void SerialReader::init(byte id)
{
  this->id = id;

  if (id == 0)
  {
    Serial.begin(19200);
  }
  else if (id == 2)
  {
    Serial2.begin(19200);
  }
  else if (id == 3)
  {
    Serial3.begin(19200);
  }
}

byte SerialReader::getId()
{
  return id;
}

String SerialReader::getMessage()
{
  String result = "";

  if (isSerialAvaliable())
  {
    incomingSerialMessage += String(read());
    incomingSerialMessage.toLowerCase();
  }

  if (incomingSerialMessage.indexOf("#") >= 0)
  {
    result = incomingSerialMessage;
    incomingSerialMessage = "";
  }

  return result;
}

bool SerialReader::isSerialAvaliable()
{
  return ((id == 0 && Serial.available() > 0) || (id == 2 && Serial2.available() > 0) || (id == 3 && Serial3.available() > 0));
}

char SerialReader::read()
{
  char result;

  if (id == 0)
  {
   result = (char) Serial.read();
  }
  else if (id == 2)
  {
   result = (char) Serial2.read();
  }
  else if (id == 3)
  {
   result = (char) Serial3.read();
  }

  return result;
}

Example usage:

    message = serial2Reader.getMessage();
    if (!message.equals(""))
    {
      receivedBySerial = serial2Reader.getId();
      handleCommand(message);
    }

thanks in advance

Fragemntation is possible because memory free shows me freeMemory()=5747 - when arduino hangs

but can some one tell me why this code is changing when lot of data come ?

Do you have an example of "lot of data" that you are receiving?

You may be interested in Serial Input Basics - simple reliable ways to receive data without using Strings.

...R