File: LeakTest1.java

package info (click to toggle)
rxtx 2.2pre2%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 6,960 kB
  • sloc: ansic: 14,367; sh: 10,742; java: 7,629; cpp: 2,717; makefile: 143
file content (35 lines) | stat: -rw-r--r-- 654 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
	
	test   :  LeakTest1
	Author :  MathWorks
	added  :  Thu Jul 26 16:43:08 MDT 2001
	Problem:  open() can leak memory in some CommAPI implementations
		  when called multiple times.
*/

import gnu.io.*;

public class LeakTest1
{
	public static void main(String args[]){
		CommPortIdentifier portId;
		SerialPort serialPort;

		int i=0;
		while (true){
			try{
				portId = CommPortIdentifier.getPortIdentifier(
								"/dev/ttyS0"
							);
				serialPort = (SerialPort)portId.open(
								"/dev/ttyS0", 2000
							);
				serialPort.close();
				System.gc();
				if(!(++i%1000 > 0))
					System.out.println(i);
			}catch (Exception ie){}
		}
	}
}