JSCH會大量使用服務器內存嗎?會

java實現一個需求用到了jsch,發現服務器內存會被佔滿。 寫了個50進程的jsch-sftp測試鏈接 put一個文件java

ExecutorService fixedThreadPool = Executors.newFixedThreadPool(50);
for (int j = 0; j < 50; j++) {
	fixedThreadPool.execute(new Thread("Thread1") {
		[@Override](https://my.oschina.net/u/1162528)
		public void run() {
			while (true){
				System.out.println(Thread.currentThread().getName());
				dosftptest();
				try {
					Thread.sleep(10*1000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}
	});
}

          total        used        free      shared  buff/cache   available

Mem: 1839 137 828 0 873 1523 Swap: 0 0 0服務器

total        used        free      shared  buff/cache   available

Mem: 1839 748 123 9 966 829 Swap: 0 0 0ide

total        used        free      shared  buff/cache   available

Mem: 1839 1052 79 14 707 495 Swap: 0 0 0測試

啓動後內存一直降低,最後穩定到70-80之間差很少。 關閉java程序後,內存恢復。 total used free shared buff/cache available Mem: 1839 106 1214 0 518 1565 Swap: 0 0 0.net

因此java經過jsch sftp,是會佔用服務器內存的,因此鏈接使用後必須進行關閉!code

相關文章
相關標籤/搜索