You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
689 B

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