Hi im new in j2me programming...
im writting a program to download documents from a server... the server send a string with the base64 code (xml-rpc)of the document.. i save that string in a StringBuffer but when the Buffer has a 1117527 lenght an outofmemoryexception is thrown...
what can i do to to save memory?.
i proved my code in a nokia n80 and the exception is thrown in that lenght.. in a nokia n82 i can download even more...
this is the code:
do{
//execute request
start = System.currentTimeMillis();
obj = request.execute();
end = System.currentTimeMillis();
//calculate next page size
//dataSize = calcSize>pingSize?calcSizeingSize;
if(obj instanceof Hashtable){
response = new DocumentResponse((Hashtable)obj);
//Refresh the indexes for new request
request.setFrom(response.getTo());//new calculated From;
request.setTo(response.getTo()+(int)dataSize);//new calculated To;
if(x==1){
System.out.println("SET");
this.data.setData(response.getData());
}
else{
System.out.println("add");
this.data.addData(response.getData());
}
}
x++;
System.gc();
//moveToStore();
System.out.println(data.getLength());
}while(!response.hasMore());
done = true;
System.out.println(data.getLength());
moveToStore(); //move the document downloaded to a permanent localization and remove partial download
the adddata and setdata functions :
public void setData(String data){
this.data = data;
sb = new StringBuffer(this.data);
}
public void addData(String data){
this.data = data;
sb.append(this.data);
}
can anyone help me???

ingSize;
Reply With Quote



