Abstract
Despite the availability of garbage collectors, programmers must manually manage non-memory finite system resources such as file descriptors. Resource leaks can gradually consume all available resources and cause programs to raise resource exhaustion exceptions. However, programmers commonly provide no effective recovery approach for resource exhaustion exceptions, which often causes programs to halt without completing their tasks. In this paper, we propose to automatically recover programs from resource exhaustion exceptions caused by resource leaks. We transform programs to catch resource exhaustion exceptions, collect leaked resources, and then retry the failure code. A resource collector is designed to identify leaked resources and safely release them. We implement our approach for Java programs. Experimental results show that our approach can successfully handle resource exhaustion exceptions caused by reported resource leaks and allow programs to complete their tasks with an average execution time increase of 2.52% and negligible bytecode size increase.
Similar content being viewed by others
References
Allan, C., Avgustinov, P., Christensen, A.S., et al., 2005. Adding trace matching with free variables to Aspectj. ACM SIGPLAN Not., 40(10):345–364. [doi:10.1145/1103845.1094839]
Arnold, M., Fink, S., Grove, D., et al., 2000. Adaptive optimization in the Jalapeno JVM. Proc. 15th ACM SIGPLAN Conf. on Object-Oriented Program ming, Systems, Languages, and Applications, p.47–65. [doi:10.1145/353171.353175]
Arnold, M., Vechev, M., Yahav, E., 2011. QVM: an efficient runtime for detecting defects in deployed systems. ACM Trans. Softw. Eng. Methodol., 21(1):2:1–2:35. [doi:10.1145/2063239.2063241]
Blackburn, S.M., Cheng, P., McKinley, K.S., 2004. Oil and water? High performance garbage collection in Java with MMTK. Proc. 26th Int. Conf. on Software Engineering, p.137–146. [doi:10.1109/ICSE.2004.1317436]
Blackburn, S.M., Garner, R., Hoffmann, C., et al., 2006. The DaCapo benchmarks: Java benchmarking development and analysis. Proc. 21st Annual ACM SIGPLAN Conf. on Object-Oriented Programming Systems, Languages, and Applications, p.169–190. [doi:10.1145/1167473.1167488]
Boehm, H.J., 2003. Destructors, finalizers, and synchronization. Proc. 30th ACM SIGPLAN-SIGACT Symp. on Principles of Programming Languages, p.262–272. [doi:10.1145/604131.604153]
Bond, M.D., McKinley, K.S., 2008. Tolerating memory leaks. Proc. 23rd ACM SIGPLAN Conf. on Object-Oriented Programming Systems Languages and Applications, p.109–126. [doi:10.1145/1449764.1449774]
Cabral, B., Marques, P., 2007. Exception handling: a field study in Java and.NET. LNCS, 4609:151–175. [doi:10.1007/978-3-540-73589-2_8]
Cabral, B., Marques, P., 2008. A case for automatic exception handling. IEEE/ACM Int. Conf. on Automated Software Engineering, p.403–406.
Carzaniga, A., Gorla, A., Mattavelli, A., et al., 2013. Automatic recovery from runtime failures. Proc. Int. Conf. on Software Engineering, p.782–791.
Chang, H., Mariani, L., Pezze, M., 2009. In-field healing of integration problems with COTS components. Proc. 31st Int. Conf. on Software Engineering, p.166–176. [doi:10.1109/ICSE.2009.5070518]
Chen, F., Roşu, G., 2007. MOP: an efficient and generic runtime verification framework. Proc. 22nd Annual ACM SIGPLAN Conf. on Object-Oriented Programming Systems and Applications, p.569–588. [doi:10.1145/1297027.1297069]
Dai, Z., Mao, X., Lei, L., et al., 2013. Resco: automatic collection of leaked resources. IEICE Trans. Inform. Syst., E96-D(1):28–39.
DeLine, R., Fähndrich, M., 2001. Enforcing high-level protocols in low-level software. Proc. ACM SIGPLAN Conf. on Programming Language Design and Implementation, p.59–69. [doi:10.1145/378795.378811]
Dobolyi, K., Weimer, W., 2008. Changing Java’s semantics for handling null pointer exceptions. 19th Int. Symp. on Software Reliability Engineering, p.47–56. [doi:10.1109/ISSRE.2008.59]
Dybvig, R.K., Bruggeman, C., Eby, D., 1993. Guardians in a generation-based garbage collector. Proc. ACM SIGPLAN Conf. on Programming Language Design and Implementation, p.207–216. [doi:10.1145/155090.155110]
Fetzer, C., Felber, P., Hogstedt, K., 2004. Automatic detection and masking of nonatomic exception handling. IEEE Trans. Softw. Eng., 30(8):547–560. [doi:10.1109/TSE.2004.35]
Friedrich, G., Fugini, M., Mussi, E., et al., 2010. Exception handling for repair in service-based processes. IEEE Trans. Softw. Eng., 36(2):198–215. [doi:10.1109/TSE.2010.8]
Guyer, S.Z., McKinley, K.S., Frampton, D., 2006. Free-me: a static analysis for automatic individual object reclamation. Proc. ACM SIGPLAN Conf. on Programming Language Design and Implementation, p.364–375. [doi:10.1145/1133981.1134024]
Hejlsberg, A., Golde, P., Wiltamuth, S., 2003. C# Language Specification. Addison Wesley.
Herlihy, M., Luchangco, V., Moir, M., 2006. A flexible framework for implementing software transactional memory. ACM SIGPLAN Not., 41(10):253–262. [doi:10.1145/1167515.1167495]
Lei, Y., Mao, X.G., Dai, Z.Y., et al., 2012. Effective fault localization approach using feedback. IEICE Trans. Inform. Syst., E95.D(9):2247–2257. [doi:10.1587/transinf.E95.D.2247]
Martin, M., Livshits, B., Lam, M.S., 2005. Finding application errors and security flaws using PQL: a program query language. Proc. 20th Annual ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages, and Applications, p.365–383. [doi:10.1145/1094811.1094840]
Park, D.A., Rice, S.V., 2006. A framework for unified resource management in Java. Proc. 4th Int. Symp. on Principles and Practice of Programming in Java, p.113–122. [doi:10.1145/1168054.1168070]
Qi, Y.H., Mao, X.G., Wen, Y.J., et al., 2012. More efficient automatic repair of large-scale programs using weak recompilation. Sci. China Inform. Sci., 55(12):2785–2799. [doi:10.1007/s11432-012-4741-1]
Shah, H.B., Gorg, C., Harrold, M.J., 2010. Understanding exception handling: viewpoints of novices and experts. IEEE Trans. Softw. Eng., 36(2):150–161. [doi:10.1109/TSE.2010.7]
Sinha, S., Shah, H., Görg, C., et al., 2009. Fault localization and repair for Java runtime exceptions. Proc. 18th Int. Symp. on Software Testing and Analysis, p.153–164. [doi:10.1145/1572272.1572291]
Torlak, E., Chandra, S., 2010. Effective interprocedural resource leak detection. Proc. 32nd ACM/IEEE Int. Conf. on Software Engineering, p.535–544. [doi:10.1145/1806799.1806876]
Vallée-Rai, R., Co, P., Gagnon, E., et al., 1999. SOOT—a Java bytecode optimization framework. Proc. Conf. Centre for Advanced Studies on Collaborative Research, p.13.
Walsh, J.D., Bordeleau, F., Selic, B., 2007. Domain analysis of dynamic system reconfiguration. Softw. Syst. Model, 6(4):355–380. [doi:10.1007/s10270-006-0038-4]
Weimer, W., Necula, G.C., 2005. Mining temporal specifications for error detection. LNCS, 3440:461–476. [doi:10.1007/978-3-540-31980-1_30]
Weimer, W., Necula, G.C., 2008. Exceptional situations and program reliability. ACM Trans. Program. Lang. Syst., 30(2):8:1–8:51. [doi:10.1145/1330017.1330019]
Wu, Q., Liang, G.T., Wang, Q.X., et al., 2011. Iterative mining of resource-releasing specifications. Proc. 26th IEEE/ACM Int. Conf. on Automated Software Engineering, p.233–242. [doi:10.1109/ASE.2011.6100058]
Author information
Authors and Affiliations
Corresponding author
Additional information
Project supported by the National Natural Science Foundation of China (Nos. 61379054 and 91318301) and the National High-Tech R&D Program (863) of China (No. 2012AA011201)
Rights and permissions
About this article
Cite this article
Dai, Zy., Mao, Xg., Chen, Lq. et al. Automatic recovery from resource exhaustion exceptions by collecting leaked resources. J. Zhejiang Univ. - Sci. C 15, 622–635 (2014). https://doi.org/10.1631/jzus.C1300352
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1631/jzus.C1300352