Mercurial > hg > Members > nobuyasu > tightVNCProxy
diff src/myVncProxy/MyRfbProto.java @ 82:0cbe556e2c54
remove item to reduce memory
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 03 Aug 2011 04:26:58 +0900 |
parents | 9109273b96dc |
children | d4236fd2efe1 |
line wrap: on
line diff
--- a/src/myVncProxy/MyRfbProto.java Wed Aug 03 03:20:39 2011 +0900 +++ b/src/myVncProxy/MyRfbProto.java Wed Aug 03 04:26:58 2011 +0900 @@ -32,7 +32,7 @@ * CheckMillis is one of new msgType for RFB 3.998. */ final static int SpeedCheckMillis = 4; - private static final int INFLATE_BUFSIZE = 1024*1024*16; + private static final int INFLATE_BUFSIZE = 1024*1024; boolean printStatusFlag = false; long startCheckTime; @@ -57,7 +57,7 @@ byte[] pngBytes; - private MulticastQueue<byte[]> multicastqueue = new MulticastQueue<byte[]>(); + private MulticastQueue<byte[]> multicastqueue = new MostRecentMultiCast<byte[]>(10); private int clients = 0; private Inflater inflater = new Inflater(); @@ -378,16 +378,18 @@ if (b[0]==RfbProto.FramebufferUpdate) { int encoding = ((b[12]*256+b[13])*256+b[14])*256+b[15]; if (encoding==RfbProto.EncodingZlib||encoding==RfbProto.EncodingZRLE) { - byte inf[] = new byte[INFLATE_BUFSIZE]; + int len; inflater.setInput(b, 20, b.length-20); - int len = inflater.inflate(inf,20,inf.length-20); - if (len==INFLATE_BUFSIZE) throw new DataFormatException(); // too large - for(int i = 0;i<20;i++) inf[i] = b[i]; - inf[16+0] = (byte) ((len >>> 24) & 0xFF); - inf[16+1] = (byte) ((len >>> 16) & 0xFF); - inf[16+2] = (byte) ((len >>> 8) & 0xFF); - inf[16+3] = (byte) ((len >>> 0) & 0xFF); - multicastqueue.put(inf); + do { + byte inf[] = new byte[INFLATE_BUFSIZE+20]; + len = inflater.inflate(inf,20,inf.length-20); + for(int i = 0;i<20;i++) inf[i] = b[i]; + inf[16+0] = (byte) ((len >>> 24) & 0xFF); + inf[16+1] = (byte) ((len >>> 16) & 0xFF); + inf[16+2] = (byte) ((len >>> 8) & 0xFF); + inf[16+3] = (byte) ((len >>> 0) & 0xFF); + multicastqueue.put(inf); + } while (len ==INFLATE_BUFSIZE); is.reset(); return; } @@ -555,14 +557,19 @@ if (b[0]==RfbProto.FramebufferUpdate) { int encoding = ((b[12]*256+b[13])*256+b[14])*256+b[15]; if (encoding==RfbProto.EncodingZlib||encoding==RfbProto.EncodingZRLE) { - byte[] c = new byte[INFLATE_BUFSIZE]; - int clen = ((b[16]*256+b[17])*256+b[18])*256+b[19]; - deflater.setInput(b,20,clen); - int len = deflater.deflate(c); + byte[] c1 = new byte[INFLATE_BUFSIZE]; + int len=0,len1,clen; + do { + clen = ((b[16]*256+b[17])*256+b[18])*256+b[19]; + deflater.setInput(b,20,clen); + len1 = deflater.deflate(c1); + if (clen==INFLATE_BUFSIZE) b = c.poll(); + len += len1; + } while(clen== INFLATE_BUFSIZE); byte[] blen = castIntByte(len); os.write(b,0,16); os.write(blen,0,4); - os.write(c,0,len); + os.write(c1,0,len); } } else os.write(b, 0, b.length);