Light-weight resource leak testing based on finalisers
Despite garbage collectors, programmers must manually manage many non-memory finite system resources' such as file descriptors and database connections. Unreleased resources result in resource leaks' that degrade application performance and can even result in system crashes. It is hard to test resource leaks because of their no immediate symptoms in the short run. There are analysis techniques to detect resource leaks statically or dynamically. However, all of them require the formal specification as input, which seriously decrease their practicability for common software developers. In this study, the authors propose an easy-to-use yet effective resource leak testing approach for Java programs based on existing finalisers of Java Application Programming Interface (API) classes. They instrument resource classes to check that the cleanup method of a resource object is called before its finaliser's execution. Otherwise, this resource object is leaked. To use this approach, programmers just add a few lines of code into their programs and no formal specifications are required. They carry out experiments on benchmarks in the literature to evaluate the incidence of object finalisation and performance cost of finalisers. Experimental results show that the authors' approach can test leaks of most system resources with high effectiveness and low overhead.
light-weight resource leak testing finalisers java java programs application program interfaces application program interfaces resource classes object finalisation performance cost program testing resource object cleanup method java api classes