我正在遭遇这种奇怪的情况。问题是,我的应用程序正在使用Asynctask从我的自定义Web服务中获取数据。在这里,在同一个任务中,它在日志中给出了IOException错误。但是,任务正常工作并返回从服务器收集所需的所有数据。意思是,似乎asynctask工作正常,但在日志中给出“IOException”。这是日志
03-22 18:39:50.880: D/dalvikvm(586): GC_FOR_MALLOC freed 2666K, 54% free 4661K/10119K, external 2108K/2633K, paused 73ms
03-22 18:39:54.370: D/PhoneWindow(586): couldn't save which view has focus because the focused view android.widget.EditText@405438d0 has no id.
03-22 18:39:58.352: E/Exception at FETCH EMPLOYEE TASK(586): java.io.IOException: Not Found
03-22 18:40:00.210: D/dalvikvm(586): GC_CONCURRENT freed 1189K, 53% free 4778K/10119K, external 2113K/2215K, paused 9ms+10ms
03-22 18:40:03.670: D/dalvikvm(586): GC_CONCURRENT freed 1360K, 53% free 4767K/10119K, external 2108K/2215K, paused 9ms+5ms
03-22 18:40:07.230: E/Exception at FETCH EMPLOYEE TASK(586): java.io.IOException: Not Found
03-22 18:40:09.070: D/dalvikvm(586): GC_CONCURRENT freed 1129K, 51% free 5041K/10119K, external 2108K/2215K, paused 8ms+6ms
03-22 18:40:12.810: E/Exception at FETCH EMPLOYEE TASK(586): java.io.IOException: Not Found
03-22 18:40:14.610: D/dalvikvm(586): GC_CONCURRENT freed 1312K, 49% free 5231K/10119K, external 2108K/2215K, paused 9ms+6ms
03-22 18:40:21.220: D/dalvikvm(586): GC_CONCURRENT freed 1354K, 47% free 5437K/10119K, external 2108K/2215K, paused 9ms+6ms
03-22 18:40:22.210: E/Exception at FETCH EMPLOYEE TASK(586): java.io.IOException: Not Found
03-22 18:40:26.880: D/dalvikvm(586): GC_CONCURRENT freed 2246K, 53% free 4803K/10119K, external 2108K/2215K, paused 19ms+7ms
03-22 18:40:27.891: E/Exception at FETCH EMPLOYEE TASK(586): java.io.IOException: Not Found
03-22 18:40:32.540: D/dalvikvm(586): GC_CONCURRENT freed 1319K, 52% free 4896K/10119K, external 2108K/2215K, paused 8ms+6ms
03-22 18:40:36.183: E/Exception at FETCH EMPLOYEE TASK(586): java.io.IOException: Not Found
03-22 18:40:38.081: D/dalvikvm(586): GC_CONCURRENT freed 1293K, 51% free 5000K/10119K, external 2108K/2215K, paused 8ms+8ms
03-22 18:40:40.330: I/dalvikvm(586): Jit: resizing JitTable from 2048 to 4096
03-22 18:40:40.780: W/IInputConnectionWrapper(586): finishComposingText on inactive InputConnection
03-22 18:40:43.390: E/Exception at FETCH EMPLOYEE TASK(586): java.io.IOException: Not Found
03-22 18:40:44.790: D/dalvikvm(586): GC_CONCURRENT freed 1715K, 54% free 4700K/10119K, external 2108K/2215K, paused 9ms+7ms
这是我的Asynctask。
public class FetchEmployeeTask extends AsyncTask<String, Void, VO_EmployeeHolder> {
VO_EmployeeHolder vEholder = new VO_EmployeeHolder();
Core core = new Core();
String _empId,_username,_password;
String _data,_url;
private static final String KEY_ID = "id";
private static final String KEY_FNAME = "first-name";
private static final String KEY_LNAME = "last-name";
private static final String KEY_DESIG = "title";
private static final String KEY_EMAIL = "email-address";
private static final String KEY_AVATAR = "avatar-url";
private static final String KEY_CELLNO = "phone-number-mobile";
@Override
protected VO_EmployeeHolder doInBackground(String... params) {
this._empId = params[0];
this._username = params[1];
this._password = params[2];
this._url = "https://somedomainhere.to.place/man/"+this._empId+".xml";
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response;
HttpHost _thost = new HttpHost("somedomainhere.to.place",443,"https");
try {
((AbstractHttpClient) httpclient).getCredentialsProvider().setCredentials(
new org.apache.http.auth.AuthScope(_thost.getHostName(),_thost.getPort()),
new org.apache.http.auth.UsernamePasswordCredentials(this._username, this._password));
response = httpclient.execute(new HttpGet(this._url));
StatusLine statusLine = response.getStatusLine();
if(statusLine.getStatusCode() == HttpStatus.SC_OK) {
InputStream _Istream = response.getEntity().getContent();
Document _Document = DomTaskParse(_Istream);
NodeList _nodeRecord = _Document.getElementsByTagName("person");
loadEmployee(_nodeRecord);
} else {
response.getEntity().getContent().close();
throw new IOException(statusLine.getReasonPhrase());
}
} catch(ClientProtocolException cpe) {
Log.e("ClientProtocolException @ FPT",cpe.toString());
} catch(Exception ex) {
Log.e("Exception at FETCH EMPLOYEE TASK",ex.toString());
}
return this.vEholder;
}
private void loadEmployee(NodeList nList) {
Element e = (Element) nList.item(0);
this.vEholder._id = core.getValue(e, KEY_ID);
this.vEholder._fname = core.getValue(e, KEY_FNAME);
this.vEholder._lname = core.getValue(e, KEY_LNAME);
this.vEholder._designation = core.getValue(e, KEY_DESIG);
this.vEholder._email = core.getValue(e, KEY_EMAIL);
this.vEholder._avatar = core.getValue(e, KEY_AVATAR);
this.vEholder._cellno = core.getValue(e, KEY_CELLNO);
}
private Document DomTaskParse(InputStream _Istream) {
try {
return new DomParserTask().execute(_Istream).get();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
答案 0 :(得分:0)
Android的垃圾收集器正在后台运行。 DVM通过调用GC清除不需要的数据,并增加此特定应用程序的分配RAM。 RAM将增加,直到它达到可以提供给应用程序的最大RAM,然后如果它仍然想要扩展,那么DVM将抛出Out of Memory Exception。