摘要
内存泄漏是云应用、Web服务、中间件等各类连续工作型软件中的一种常见缺陷,它会导致程序运行速度减慢、资源耗尽崩溃等软件稳定性问题。现有测试一般以较长周期运行测试用例来检测泄漏缺陷,用于检测泄漏的测试用例通常需要运行数小时以上才能产生足以暴露泄漏的内存表现。整个测试过程代价高昂,若对测试用例不加筛选,可能会耗费大量的时间在暴露泄漏可能性低的测试用例上,降低了泄漏发现的效率。为了弥补现有技术的不足,并解决Java Web程序长时间运行的内存泄漏缺陷不易发现、不易诊断及不易修复的难题,文中对内存泄漏的发现技术进行了研究,提出了基于机器学习的内存泄漏测试脚本预测方法,通过构建内存特征模型,对存在内存泄漏的脚本进行训练及预测,基于训练的模型进行脚本内存泄漏风险值预测,并给出相应的参数打分,以指导后续的脚本重组,从而预测获取更可能造成内存泄漏的功能测试脚本。同时,提出了脚本重组优化方法,改善其缺陷揭示能力。对预测和重组后的脚本进行优先测试,可以加速泄漏缺陷的发现。最后通过案例验证表明了所提框架具有较强的泄漏发现能力,重组优化后的测试脚本在发现缺陷的速度方面比普通脚本高出一倍以上,从而缩短了内存膨胀问题的暴露时间,达到了提高测试效率以及保障软件质量的目的。
Memory leak is a common defect in continuous working software,such as cloud applications,web service,middleware,etc.It can affect the stability of software applications,lead to run in bad performance and even crash.To clearly observe memory leaks,the test cases toward them need to execute longer time in order to generate significant memory pressure.The cost of memory leaks testing is expensive.If the execution orders of test cases are not optimized,we may waste lots of time on the test cases that are not likely to reveal faults before finding test cases that really containing memory leaks.This seriously reduces the efficiency of fault discovery.In order to make up for the shortcomings of the existing technology and solve the problems of the me-mory leak of Java Web program while running for a long time,which is not easy to find,diagnose and repair,this paper studies the memory leak detection technology,proposes the memory leak test script prediction method based on machine learning.The method trains and predicts the script with memory leak by building the memory feature model.Then,based on the training model,it predicts the risk value of script memory leak,and gives the corresponding parameter scores,to guide the subsequent script reorganization,can predict and obtain the function test script that is more likely to cause memory leak.At the same time,a script reorganization optimization method is proposed to improve its defect revealing ability.Priority testing of predicted and recombined scripts can accelerate the detection of leakage defects.Finally,a case study shows that the proposed framework has strong leak detection ability.The speed of defect detection of the optimized test script can be more than twice as fast as that of the common script,thus accelerating the exposure time of memory expansion problem,achieving the purpose of improving test efficiency and ensuring software quality.
作者
李吟
李必信
LI Yin;LI Bi-xin(School of Computer Science and Engineering,Southeast University,Nanjing 211189,China;Jiangsu Automation Research Institute,Lianyungang,Jiangsu 222006,China)
出处
《计算机科学》
CSCD
北大核心
2020年第9期31-39,共9页
Computer Science
关键词
内存泄漏
泄漏预测模型
机器学习
测试脚本
脚本重组
Memory leak
Memory leak prediction model
Machine learning
Test script
test script reconstruction