Debian Codegraph @

contrib/LeakTest1.java

raw symbols SCIP
1 /*
2
3 test : LeakTest1
4 Author : MathWorks
5 added : Thu Jul 26 16:43:08 MDT 2001
6 Problem: open() can leak memory in some CommAPI implementations
7 when called multiple times.
8 */
9
10 import gnu.io.*;
11
12 public class LeakTest1
13 {
14 public static void main(String args[]){
15 CommPortIdentifier portId;
16 SerialPort serialPort;
17
18 int i=0;
19 while (true){
20 try{
21 portId = CommPortIdentifier.getPortIdentifier(
22 "/dev/ttyS0"
23 );
24 serialPort = (SerialPort)portId.open(
25 "/dev/ttyS0", 2000
26 );
27 serialPort.close();
28 System.gc();
29 if(!(++i%1000 > 0))
30 System.out.println(i);
31 }catch (Exception ie){}
32 }
33 }
34 }
35