Re: [JSch-users] Session hang when connected with openSSH
Status: Alpha
Brought to you by:
ymnk
From: Lothar K. <jo...@ki...> - 2014-06-18 14:12:02
|
Am 18.06.2014 15:17, schrieb aarthit 2014: > InputStream io1 = System.in; > byte[] buf = new byte[32768]; > int i = -1; > > try { > * _i=io1.read(buf, 0, 32768);_ > * > String str = new String(buf); > System.out.println ("I read " + buf + "as string" + str); > } > catch (Exception e) > { > System.out.println("Excecption received" + e ); > } > } > } > > > In this program when we change the value of the third parameter > of the read call to value greater than 26608 we get the following > exception when run in windows XP with java version 1.6.0_22 > * > java.io.IOException: Not enough storage is available to process this command > * > > But the same program is working fine when it is run in windows 7 > machine with same JRE version even if we increase the values upto 32767. The error-message comes from the operating system and has nothing to do with Java/JSCH. See e.g. http://answers.microsoft.com/en-us/windows/forum/windows_7-hardware/not-enough-storage-is-available-to-process-this/9624b57d-ea4c-41fa-aae0-b52e99b69fab That's the first Google-Hit covering that error-message. As you can see, the error can also occur on later versions of Windows and I've seen this kind of error on other operating systems as well (e.g. with a JVM on a BS2000-system - don't ask ;-) The way you read in the data is not good practice anyway and can lead to problems on Windows 7 as well, e.g. if not all data resides in one TCP-packet and the seconds arrives delayed. A better approach for that e.g. is byte[] buf = new byte[maxLength] int read; int offset = 0; while (offset < buf.length && (read = io1.read(buf, offset, Math.min(4096, buf.length - offset)) != -1){ offset += read; } Cheers, Lothar |