Fixed stream memory leak
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
1d37ec04a8
commit
bb52b2737d
BIN
bin/SigShare.jar
BIN
bin/SigShare.jar
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 78 KiB |
Binary file not shown.
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 40 KiB |
@ -130,7 +130,7 @@ public class SigShare {
|
|||||||
while (in.available()>0) {
|
while (in.available()>0) {
|
||||||
if (stream==null) {
|
if (stream==null) {
|
||||||
//System.out.println("Stream opened.");
|
//System.out.println("Stream opened.");
|
||||||
stream=new BufferedOutputStream(new FileOutputStream(new File("screenshot_out.jpg")));
|
stream=new BufferedOutputStream(new FileOutputStream(new File("screenshot_out.jpg"),true));
|
||||||
}
|
}
|
||||||
int val = in.read();
|
int val = in.read();
|
||||||
stream.write(val);
|
stream.write(val);
|
||||||
@ -141,7 +141,7 @@ public class SigShare {
|
|||||||
dashCount=0;
|
dashCount=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dashCount>=10&&stream!=null) {
|
if (dashCount>=10) {
|
||||||
stream.close();
|
stream.close();
|
||||||
stream=null;
|
stream=null;
|
||||||
dashCount=0;
|
dashCount=0;
|
||||||
@ -155,6 +155,7 @@ public class SigShare {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
out.writeChars("Done\r\n");
|
out.writeChars("Done\r\n");
|
||||||
|
stream=new BufferedOutputStream(new FileOutputStream(new File("screenshot_out.jpg"),false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,9 @@ public class Panel extends JPanel implements Runnable {
|
|||||||
// ask ImageProducer to update image
|
// ask ImageProducer to update image
|
||||||
mImageProducer.newPixels();
|
mImageProducer.newPixels();
|
||||||
// draw it on panel
|
// draw it on panel
|
||||||
g.drawImage(this.imageBuffer.getScaledInstance(getWidth(), getHeight(), Image.SCALE_FAST), 0, 0, this);
|
Image f = this.imageBuffer.getScaledInstance(getWidth(), getHeight(), Image.SCALE_FAST);
|
||||||
|
g.drawImage(f, 0, 0, this);
|
||||||
|
f.flush();
|
||||||
|
|
||||||
|
|
||||||
if (window!=null&&System.currentTimeMillis()-lastSecond>=1000) {
|
if (window!=null&&System.currentTimeMillis()-lastSecond>=1000) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user