2012-03-22 2 views
0

나는 이상한 상황으로 고통 받고 있습니다. 문제는 내 응용 프로그램이 Asynctask를 사용하여 사용자 정의 웹 서비스에서 데이터를 가져 오는 것입니다. 동일한 작업에서 로그에 IOException 오류가 발생합니다. 그러나 작업이 잘 작동하고 서버에서 수집하는 데 필요한 모든 데이터를 반환합니다. 의미하면서, 그것은 asynctask 잘 작동하지만 "IOException"을주는 로그에있는 것 같습니다. 여기에 로그가 있습니다안드로이드 - 로그에 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 [email protected] 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

안드로이드의 가비지 콜렉터는 백그라운드에서 실행됩니다. DVM은 GC를 호출하고이 특정 응용 프로그램에 할당 된 RAM을 늘려 불필요한 데이터를 삭제합니다. RAM은 응용 프로그램에 제공 할 수있는 최대 RAM에 도달 할 때까지 증가하고 이후에도 확장하려면 DVM에서 Out of Memory Exception을 발생시킵니다.

+0

그래서 긍정적이거나 부정적입니까? 지금 어떻게해야합니까? –

+0

걱정할 필요가 없습니다. DVM은 그러한 문제를 처리 할 것입니다. 그러나 메모리 사용을 관리해야합니다. 최대한 메모리 사용량을 줄일 수 있습니다. 이것은 더 큰 메모리를 다루는 시스템이나 서버가 아닌 스마트 폰입니다. 당신이 할 수있는 모든 것을 최적화하십시오. – Pavandroid

+0

음 괜찮아요! 고마워요! –

관련 문제