[jcifs] OutOfMemoryError when writing with SmbFileOutputStream
Krum Valkov
k.valkov at bg.seeburger.com
Mon Nov 2 02:19:11 MST 2009
Hi,
I managed to reproduce the error with a simple java program without using the
JBoss server. Here is the main method and the whole stack trace. I tryed to
start it few times and the time interval, before the error appears is different,
but it always shows up.
47 public static void main(String[] args)
48 throws IOException
49 {
50 int bufferSize = 1024 * 512;
51 byte[] buffer = new byte[bufferSize];
52 for (int i = 0; i < buffer.length; i++)
53 {
54 buffer[i] = (byte)(i % Byte.MAX_VALUE);
55 }
56 System.out.println("START");
57 NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(DOMAIN,
USER_NAME, PASSWORD);
58 SmbFile dir = new SmbFile(DIRECTORY, auth);
59 if (!dir.exists())
60 {
61 dir.mkdirs();
62 }
63 SmbFile file = new SmbFile(dir.getPath() + "F" +
System.currentTimeMillis(), auth);
64 if (!file.exists())
65 {
66 file.createNewFile();
67 }
68 System.out.println("SMB file " + file.getPath() + " created!");
69 SmbFileOutputStream out = new SmbFileOutputStream(file);
70 int iterations = 2000;
71 System.out.println("Start writing");
72 long startTime = System.currentTimeMillis();
73 for (int i = 0; i < iterations; i++)
74 {
75 out.write(buffer, 0, buffer.length);
76 }
77 long endTime = System.currentTimeMillis();
78 String writingTime = (endTime - startTime) / 1000 + " seconds and " +
(endTime - startTime) % 1000 + " milliseconds";
79 System.out.println("Writing finished in " + writingTime);
80 }
Exception in thread "main" java.lang.OutOfMemoryError: unable to create new
native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:597)
at jcifs.UniAddress.lookupServerOrWorkgroup(UniAddress.java:173)
at jcifs.UniAddress.getAllByName(UniAddress.java:290)
at jcifs.UniAddress.getByName(UniAddress.java:245)
at jcifs.smb.Dfs.getTrustedDomains(Dfs.java:62)
at jcifs.smb.Dfs.resolve(Dfs.java:146)
at jcifs.smb.SmbFile.resolveDfs(SmbFile.java:667)
at jcifs.smb.SmbFile.send(SmbFile.java:730)
at jcifs.smb.SmbFileOutputStream.writeDirect(SmbFileOutputStream.java:245)
at jcifs.smb.SmbFileOutputStream.write(SmbFileOutputStream.java:216)
at com.seeburger.krum.test.TestFileStore.main(TestFileStore.java:75)
More information about the jCIFS
mailing list