Light-Weight Test Oracles for Resource Leaks Based on Finalizers

Ziying Dai, Xiaoguang Mao, Yuhua Qi, Kerong Ben · 2012

Garbage collectors automatically manage memory in an elegant way. However, finalization performs poorly in reclaiming finite system resources such as file descriptors and database connections, especially in Java. Resource leaks degrade application performance and can even result in system crashes. Unfortunately, it is hard to test resource leaks because they have no immediate symptoms. In this paper, we first investigate Java API classes for the usage of finalizers. Based on the common usage pattern of these finalizers, we then propose a lightweight, easy-to-use yet effective resource leak testing approach called Orbaf. Orbaf instruments resource classes to inspect whether the cleanup method of a resource object is called before its finalizer's execution. Test cases are also optionally instrumented to improve the incidence of object finalization. Orbaf can detect leaks of most system resources and does not require any formal specifications. It can be handily used by common software developers. Experiments show that Orbaf has high effectiveness and low overhead.

Read the paper · More papers on PaperTik