# HG changeset patch
# User oc
# Date 1398677123 -32400
# Node ID f1938dd3b518cc20fd8214bf4e10aa0cc3ea3937
# Parent 35f761bcb12c53fc41ec8be2619c547bae41e3b9
don't heap space error.
diff -r 35f761bcb12c -r f1938dd3b518 .classpath
--- a/.classpath Fri Apr 18 11:17:34 2014 +0900
+++ b/.classpath Mon Apr 28 18:25:23 2014 +0900
@@ -1,10 +1,10 @@
+
-
-
-
-
+
+
+
diff -r 35f761bcb12c -r f1938dd3b518 .settings/org.eclipse.jdt.core.prefs
--- a/.settings/org.eclipse.jdt.core.prefs Fri Apr 18 11:17:34 2014 +0900
+++ b/.settings/org.eclipse.jdt.core.prefs Mon Apr 28 18:25:23 2014 +0900
@@ -1,11 +1,13 @@
+#
+#Mon Apr 28 16:04:44 JST 2014
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.7
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.7
diff -r 35f761bcb12c -r f1938dd3b518 build.gradle
--- a/build.gradle Fri Apr 18 11:17:34 2014 +0900
+++ b/build.gradle Mon Apr 28 18:25:23 2014 +0900
@@ -76,14 +76,14 @@
archives noSshJar
}
-//uploadArchives {
-// repositories {
-// add(new org.apache.ivy.plugins.resolver.FileSystemResolver()) {
-// addArtifactPattern("$projectDir/dist/${project.baseName}-${project.version}/[artifact].[ext]")
-// }
-// }
-// uploadDescriptor = false
-//}
+uploadArchives {
+ repositories {
+ add(new org.apache.ivy.plugins.resolver.FileSystemResolver()) {
+ addArtifactPattern("$projectDir/dist/${project.baseName}-${project.version}/[artifact].[ext]")
+ }
+ }
+ uploadDescriptor = false
+}
task dist(dependsOn: uploadArchives)
diff -r 35f761bcb12c -r f1938dd3b518 src/main/java/jp/ac/u_ryukyu/treevnc/MulticastQueue.java
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/MulticastQueue.java Fri Apr 18 11:17:34 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/MulticastQueue.java Mon Apr 28 18:25:23 2014 +0900
@@ -1,5 +1,6 @@
package jp.ac.u_ryukyu.treevnc;
+import java.nio.ByteBuffer;
import java.util.concurrent.CountDownLatch;
public class MulticastQueue
@@ -11,7 +12,40 @@
{
tail = new Node(null);
}
+
+ /**
+ * @param size
+ * @return
+ *
+ * try to allocate byteBuffer.
+ * wait until heap is available.
+ *
+ *
+ */
+ public ByteBuffer allocate(int size)
+ {
+ ByteBuffer b=null;
+ while(true){
+ try{
+ b = ByteBuffer.allocate(size);
+ }catch(OutOfMemoryError e){
+ System.err.println("multicastqueue : wait for heap : " + e);
+ }
+ if(b!=null){
+ break;
+ }
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ }
+ }
+ return b;
+ }
+ public synchronized void heapAvailable() {
+ notifyAll();
+ }
+
public synchronized void put(T item)
{
Node next = new Node(item);
@@ -43,7 +77,6 @@
}catch(InterruptedException _e){
continue;
}
-// item = node.getItem();
item = next.getItem();
node = next;
} while ( item == null);
diff -r 35f761bcb12c -r f1938dd3b518 src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java Fri Apr 18 11:17:34 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java Mon Apr 28 18:25:23 2014 +0900
@@ -182,6 +182,8 @@
os.write(b.array(), b.position(), b.limit());
}
os.flush();
+ bufs = null;
+ multicastqueue.heapAvailable();
}
};
clients++;
diff -r 35f761bcb12c -r f1938dd3b518 src/main/java/jp/ac/u_ryukyu/treevnc/client/MyRfbProtoClient.java
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/MyRfbProtoClient.java Fri Apr 18 11:17:34 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/MyRfbProtoClient.java Mon Apr 28 18:25:23 2014 +0900
@@ -226,7 +226,7 @@
public int zip(Deflater deflater, LinkedList inputs,
int inputIndex, LinkedList outputs) throws IOException {
int len = 0;
- ByteBuffer c1 = ByteBuffer.allocate(INFLATE_BUFSIZE);
+ ByteBuffer c1 = multicastqueue.allocate(INFLATE_BUFSIZE);
while (inputIndex < inputs.size()) {
ByteBuffer b1 = inputs.get(inputIndex++);
deflater.setInput(b1.array(), b1.position(), b1.remaining());
@@ -249,7 +249,7 @@
if (c1.remaining() == 0) {
c1.flip();
outputs.addLast(c1);
- c1 = ByteBuffer.allocate(INFLATE_BUFSIZE);
+ c1 = multicastqueue.allocate(INFLATE_BUFSIZE);
}
}
} while (len1 > 0 || !deflater.needsInput()); // &&!deflater.finished());
@@ -277,7 +277,7 @@
int inputIndex, LinkedList outputs, int bufSize)
throws DataFormatException {
int len = 0;
- ByteBuffer buf = ByteBuffer.allocate(bufSize);
+ ByteBuffer buf = multicastqueue.allocate(bufSize);
while (inputIndex < inputs.size()) {
ByteBuffer input = inputs.get(inputIndex++);
inflater.setInput(input.array(), input.position(), input.limit());
@@ -293,7 +293,7 @@
if (buf.remaining() == 0) {
buf.flip();
outputs.addLast(buf);
- buf = ByteBuffer.allocate(bufSize);
+ buf = multicastqueue.allocate(bufSize);
}
}
} while (!inflater.needsInput());
@@ -308,8 +308,8 @@
public void readSendData(int dataLen, Reader reader)
throws TransportException {
LinkedList bufs = new LinkedList();
- ByteBuffer header = ByteBuffer.allocate(16);
- ByteBuffer serial = ByteBuffer.allocate(8);
+ ByteBuffer header = multicastqueue.allocate(16);
+ ByteBuffer serial = multicastqueue.allocate(8);
reader.mark(dataLen+8); // +8 is serialnum
reader.readBytes(serial.array(),0,8);
serial.limit(8);
@@ -321,10 +321,10 @@
|| encoding == EncodingType.ZLIB.getId()) { // ZRLEE is
// already
// recompressed
- ByteBuffer len = ByteBuffer.allocate(4);
+ ByteBuffer len = multicastqueue.allocate(4);
reader.readBytes(len.array(), 0, 4);
len.limit(4);
- ByteBuffer inputData = ByteBuffer.allocate(dataLen - 20);
+ ByteBuffer inputData = multicastqueue.allocate(dataLen - 20);
reader.readBytes(inputData.array(), 0, inputData.capacity());
inputData.limit(dataLen - 20);
LinkedList inputs = new LinkedList();
@@ -341,7 +341,7 @@
unzip(inflater, inputs, 0, out, INFLATE_BUFSIZE);
// dump32(inputs);
int len2 = zip(nDeflater, out, 0, bufs);
- ByteBuffer blen = ByteBuffer.allocate(4);
+ ByteBuffer blen = multicastqueue.allocate(4);
blen.putInt(len2);
blen.flip();
bufs.addFirst(blen);
@@ -360,7 +360,7 @@
bufs.add(serial);
bufs.add(header);
if (dataLen > 16) {
- ByteBuffer b = ByteBuffer.allocate(dataLen - 16);
+ ByteBuffer b = multicastqueue.allocate(dataLen - 16);
reader.readBytes(b.array(), 0, dataLen - 16);
b.limit(dataLen - 16);
bufs.add(b);
@@ -396,7 +396,7 @@
@Override
public void readCheckDelay(Reader reader) throws TransportException {
- ByteBuffer buf = ByteBuffer.allocate(24);
+ ByteBuffer buf = multicastqueue.allocate(24);
reader.readBytes(buf.array(), 0, 24);
LinkedList sendData = new LinkedList();
diff -r 35f761bcb12c -r f1938dd3b518 src/main/java/jp/ac/u_ryukyu/treevnc/server/MyRfbProtoProxy.java
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/MyRfbProtoProxy.java Fri Apr 18 11:17:34 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/MyRfbProtoProxy.java Mon Apr 28 18:25:23 2014 +0900
@@ -165,7 +165,7 @@
public int zip(Deflater deflater, LinkedList inputs,
int inputIndex, LinkedList outputs) throws IOException {
int len = 0;
- ByteBuffer c1 = ByteBuffer.allocate(INFLATE_BUFSIZE);
+ ByteBuffer c1 = multicastqueue.allocate(INFLATE_BUFSIZE);
while (inputIndex < inputs.size()) {
ByteBuffer b1 = inputs.get(inputIndex++);
deflater.setInput(b1.array(), b1.position(), b1.remaining());
@@ -188,7 +188,7 @@
if (c1.remaining() == 0) {
c1.flip();
outputs.addLast(c1);
- c1 = ByteBuffer.allocate(INFLATE_BUFSIZE);
+ c1 = multicastqueue.allocate(INFLATE_BUFSIZE);
}
}
} while (len1 > 0 || !deflater.needsInput()); // &&!deflater.finished());
@@ -216,7 +216,7 @@
int inputIndex, LinkedList outputs, int bufSize)
throws DataFormatException {
int len = 0;
- ByteBuffer buf = ByteBuffer.allocate(bufSize);
+ ByteBuffer buf = multicastqueue.allocate(bufSize);
while (inputIndex < inputs.size()) {
ByteBuffer input = inputs.get(inputIndex++);
inflater.setInput(input.array(), input.position(), input.limit());
@@ -232,7 +232,7 @@
if (buf.remaining() == 0) {
buf.flip();
outputs.addLast(buf);
- buf = ByteBuffer.allocate(bufSize);
+ buf = multicastqueue.allocate(bufSize);
}
}
} while (!inflater.needsInput());
@@ -270,7 +270,7 @@
*/
public void readSendData(int dataLen, Reader is) throws TransportException {
LinkedList bufs = new LinkedList();
- ByteBuffer header = ByteBuffer.allocate(16);
+ ByteBuffer header = multicastqueue.allocate(16);
is.readBytes(header.array(), 0, 16);
header.limit(16);
if (header.get(0) == FramebufferUpdate) {
@@ -279,10 +279,10 @@
|| encoding == EncodingType.ZLIB.getId()) { // ZRLEE is
// already
// recompressed
- ByteBuffer len = ByteBuffer.allocate(4);
+ ByteBuffer len = multicastqueue.allocate(4);
is.readBytes(len.array(), 0, 4);
len.limit(4);
- ByteBuffer inputData = ByteBuffer.allocate(dataLen - 20);
+ ByteBuffer inputData = multicastqueue.allocate(dataLen - 20);
is.readBytes(inputData.array(), 0, inputData.capacity());
// System.out.println(dataLen);
@@ -303,47 +303,33 @@
try {
unzip(inflater, inputs, 0, out, INFLATE_BUFSIZE);
len2 = zip(nDeflater, out, 0, bufs);
+ out = null;
+ multicastqueue.heapAvailable();
} catch (DataFormatException e) {
throw new TransportException(e);
} catch (IOException e) {
throw new TransportException(e);
}
- //if(dataLen<=64000)
- ByteBuffer blen = ByteBuffer.allocate(4);
+
+ ByteBuffer blen = multicastqueue.allocate(4);
blen.putInt(len2);
blen.flip();
bufs.addFirst(blen);
bufs.addFirst(header);
- ByteBuffer serialNum = ByteBuffer.allocate(8);
+ ByteBuffer serialNum = multicastqueue.allocate(8);
serialNum.putLong(counter++);
serialNum.flip();
bufs.addFirst(serialNum);
- /*
- if(i++%50 == 0) {
- LinkedList check = new LinkedList();
- ByteBuffer test = ByteBuffer.allocate(8);
- ByteBuffer header2 = ByteBuffer.allocate(16);
- header2.limit(16);
- header2.put((byte)11);
- header2.putInt(12, EncodingType.ZRLEE.getId());
- header2.position(0);
- test.putLong(System.currentTimeMillis());
- test.flip();
- check.addFirst(test);
- check.addFirst(header2);
- multicastqueue.put(check);
- }
- */
multicastqueue.put(bufs);
- // is.reset();
+
return;
}
bufs.add(header);
if (dataLen > 16) {
- ByteBuffer b = ByteBuffer.allocate(dataLen - 16);
+ ByteBuffer b = multicastqueue.allocate(dataLen - 16);
is.readBytes(b.array(), 0, dataLen - 16);
b.limit(dataLen - 16);
bufs.add(b);
diff -r 35f761bcb12c -r f1938dd3b518 src/viewer_swing/java/com/glavsoft/viewer/TreeViewer.java
--- a/src/viewer_swing/java/com/glavsoft/viewer/TreeViewer.java Fri Apr 18 11:17:34 2014 +0900
+++ b/src/viewer_swing/java/com/glavsoft/viewer/TreeViewer.java Mon Apr 28 18:25:23 2014 +0900
@@ -66,9 +66,9 @@
+ "-v: VNCViewer\n"
+ "-r: TreeVNCProxy for RemoteHost. you should input parameter host and port\n"
+ "--host hostname: set host name\n"
- + "--retina: TreeVNC proxy for retina.this mode can select screen range.\n"
- + "--width w: set display width\n"
- + "--height h: set display height\n");
+ + "--retina: TreeVNC proxy for retina.this mode can select screen range."
+ + "--width w: set display width"
+ + "--height h: set display height");
}
}
}