Statistics
| Revision:

root / trunk / extensions / extGPS / test / LeakTest1.java @ 11445

History | View | Annotate | Download (721 Bytes)

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.CommPortIdentifier;
11
import gnu.io.SerialPort;
12

    
13
public class LeakTest1
14
{
15
        public static void main(String args[]){
16
                CommPortIdentifier portId;
17
                SerialPort serialPort;
18

    
19
                int i=0;
20
                while (true){
21
                        try{
22
                                portId = CommPortIdentifier.getPortIdentifier(
23
                                                                "COM3" //"/dev/ttyS0"
24
                                                        );
25
                                serialPort = (SerialPort)portId.open(
26
                                                                "COM3", 4800 //"/dev/ttyS0", 2000
27
                                                        );
28
                                serialPort.close();
29
                                System.gc();
30
                                if(!(++i%1000 > 0))
31
                                        System.out.println(i);
32
                        }catch (Exception ie){}
33
                }
34
        }
35
}
36