자바 다운로더를 만들고 내 wampserver에서 900MB 파일을 다운로드하면 올바르게 작동하지만 램 사용량을 확인하면 그만큼 늘어납니다. 그 이유는 무엇입니까? IDM을 사용하여 동일한 파일 형식을 내 wampserver에 다운로드했는데 많은 램을 사용하지 않았습니다 프로세스 및 디스크 사용량이 약 50MB 및 5 % 컵 인 자바 다운로더를 볼 때 성능 탭에서 성능을 볼 때 RAM이 많이 증가합니다. http://i.stack.imgur.com/zfxNv.pngwampserver에서 java로 파일 다운로드
내 응용 프로그램이 동시에이 파일을 다운로드 8 스레드를 만들이 내 코드 :
private void downloadFile() {
try {
this.response = this.con.getInputStream();
this.bis = new BufferedInputStream(this.response, 32 * 1024);
this.responseContentSize = this.con.getContentLength();
if (this.responseContentSize == (this.end_range - this.start_range) + 1) {
int MAX_BUFFER_SIZE = 32*1024;
byte buffer[] = new byte[MAX_BUFFER_SIZE];
makeTmpFile();
out = new FileOutputStream(this.tmpdir + this.tmpFilename);
bos = new BufferedOutputStream(out, 32 * 1024);
while (true) {
int r = this.bis.read(buffer, 0, this.MAX_BUFFER_SIZE);
if (r == -1)
break;
bos.write(buffer, 0, r);
downloadedBytes += r;
}
if (bos != null)
bos.close();
if (out != null)
out.close();
if (bis != null)
bis.close();
if (response != null)
response.close();
}
} catch (IOException e) {
sharedDownloadStatus.setCell(this.threadIndex, STATUS, 0);//error
log.setLog("func : downloadFile =>\n couldnt download file\n" + e.getMessage());
}
}
내 코드의 일부를, 무슨 뜻? 내 버퍼 배열이 while 루프 밖에 있기 때문에 – wineo
이 스 니펫이주기 자체에서 실행되지 않습니까? 당신은 8 스레드 언급. – Basilevs
ok 8thread의 크기가 32KB 인 8 버퍼를 8 * 32KB로 사용하므로 많은 양의 RAM이 필요하지 않으므로 왜 그렇게 많이 차지합니까? 나는 너의 의미를 이해하지 못 하느냐? 죄송합니다. 제게 설명해주십시오. – wineo