To prevent memory leaks you should cancel any COBOL programs you have loaded from Java before the owning Java object is subjected to garbage collection. Use the following call from the Finalize method of the Java object:
RuntimeSystem.cobcancel("program")
where program is the name of a COBOL program loaded using a RuntimeSystem.cobload() call. The following is an example of a Finalize method in a Java program:
private void Finalize() { try { RuntimeSystem.cobcancel("demoFinalizers"); System.out.println("demoFinalizers - finalize'ed"); } catch(Exception e) { System.out.println( "Error during finalize : "+e.getMessage()); } }