out of memory error
hi i get the above error when a user inputs a username and password in my system on the second attempt.
here is the following code: the username and password is retrieved from two textfields and stores has Strings. The username and password than gets sent back to a server and later the server will send some data telling the user that the password is incorrect or correct.
When a user logs in succesfuly at the first attempt it works but on the 2nd attempt, the program gives me a out of memory error.
public String login(String user, String pass)
{
String response =" ";
try
{
String coin_cmd ="99" +"\n"+"\0";
String coin_val ="0.1" +"\n"+"\0";
String cmd1 ="100" +"\n"+"\0";
String cmd2 ="101"+"\n"+"\0";
String p = pass +"\n"+"\0";
String u = user +"\n"+"\0";
os.write(u.getBytes());
os.flush();
os.write(p.getBytes());
os.flush();
line1[0] = getResponse();
String bad ="BADLOGIN";
String status = line1[0].substring(12,20);
if(status.equals(bad))
{
response = bad;
}
else
{
os.write(coin_cmd.getBytes());//get default coin value
os.flush();
os.write(coin_val.getBytes());
os.flush();
os.write(cmd1.getBytes());
os.flush();
os.write(cmd2.getBytes());
os.flush();
for(int i=1;i<4;i++)
{
line1[i] = getResponse();
}
//send balance
response = line1[0];
line = response;
}
}
catch(Exception e)
{
e.printStackTrace();
}
//reset it
for(int c=0; c<6 ;c++)
{
line1[c] =" ";
}
return response;
}
Below is the canvas code. Note that p and u are the password and username data gathered from the text field
line = root.login(u,p);
String bad ="BADLOGIN";
if(line.equals(bad))
{
Alert in =new Alert ("Error");
in.setString("Username or password is invalid");
in.setTimeout (3000);
Display.getDisplay(root).setCurrent(in,this);
line ="";
line1 ="";
line2 ="";
}
else
{
//display error message
Alert in =new Alert ("Logged In");
in.setString("You have succesfuly logged into the system");
in.setTimeout (3000);
Display.getDisplay(root).setCurrent(in,this);
loggedIn =true;
logged ="Log out";
//line = "";
line1 ="";
line2 ="";
}

