Systematic Testing for Resource Leaks in Android Applications

26
Systema(c Tes(ng for Resource Leaks in Android Applica(ons PRESTO: Program Analyses and So5ware Tools Research Group, Ohio State University Dacong (Tony) Yan, Shengqian Yang, Atanas Rountev Ohio State University

description

The use of mobile devices and the complexity of their software continue to grow rapidly. This growth presents significant challenges for software correctness and performance. In addition to traditional defects, a key consideration are defects related to the limited resources available on these devices. Resource leaks in an application, due to improper management of resources, can lead to slowdowns, crashes, and negative user experience. Despite a large body of existing work on leak detection, testing for resource leaks remains a challenging problem. We propose a novel and comprehensive approach for systematic testing for resource leaks in Android software. Similar to existing testing techniques, the approach is based on a GUI model, but is focused specifically on coverage criteria aimed at resource leak defects. These criteria are based on neutral cycles: sequences of GUI events that should have a "neutral" effect and should not lead to increases in resource usage. We have defined several test coverage criteria based on different categories of neutral cycles in the GUI model. This approach is informed by knowledge of typical causes of resource leaks in Android software. We have also developed LeakDroid, a tool that generates test cases to trigger repeated execution of neutral cycles. When the test cases are executed, resource usage is monitored for suspicious behaviors. The approach has been evaluated on several Android applications. The evaluation demonstrates that the proposed test generation effectively uncovers a variety of resource leaks.

Transcript of Systematic Testing for Resource Leaks in Android Applications

Page 1: Systematic Testing for Resource Leaks in Android Applications

Systema(c*Tes(ng*for*Resource*Leaks*in*Android*Applica(ons*

PRESTO:(Program(Analyses(and(So5ware(Tools(Research(Group,(Ohio(State(University(

Dacong (Tony) Yan, Shengqian Yang, Atanas Rountev

Ohio State University

Page 2: Systematic Testing for Resource Leaks in Android Applications

Background(•  Android(devices(

•  Currently(lead(the(smartphone(market(•  Direct(impact(on(millions(of(users(•  Require(novel(techniques(for(improved(so5ware(quality(

•  Resource(leaks(•  Examples(of(resources:(memory((managed(or(naIve),(database(cursors,(binders,(bitmaps,(etc.(

•  Slowdowns(and(crashes(•  Limited(resources(on(handheld(devices(

**

Page 3: Systematic Testing for Resource Leaks in Android Applications

An(Example:(APV(

**

Open PDF

Close PDF

Page 4: Systematic Testing for Resource Leaks in Android Applications

NaIve(Memory(ConsumpIon(Comparison(

**

Page 5: Systematic Testing for Resource Leaks in Android Applications

Our(Proposal(•  Challenges:(developing(leakQtriggering(test(cases(and(test(inputs(

•  Insight(•  Leaks(triggered(by(repeated(operaIons(•  Focus(on(neutral(cycles,(repeated(operaIons(that(should(not(increase(resource(usage(

•  ModelQbased(test(generaIon(•  Input:(a(model(for(applicaIon(GUI,(called(GUI(model(•  Generate(test(cases(to(cover(neutral(cycles(in(the(GUI(model(for(leak(discovery(

**

Page 6: Systematic Testing for Resource Leaks in Android Applications

GUI(Model(•  DefiniIon(

•  A(directed(graph(G=(N,(E)(•  N:(GUI(states,(i.e.(GUI(enIIes(and(their(relaIonships(•  E:(transiIons(between(states(triggered(by(events(

**

Page 7: Systematic Testing for Resource Leaks in Android Applications

GUI(Model(for(APV(

Page 8: Systematic Testing for Resource Leaks in Android Applications

GUI(Model(for(APV(

Page 9: Systematic Testing for Resource Leaks in Android Applications

GUI(Model(for(APV(

Page 10: Systematic Testing for Resource Leaks in Android Applications

GUI(Model(•  DefiniIon(

•  A(directed(graph(G=(N,(E)(•  N:(GUI(states,(i.e.(GUI(enIIes(and(their(relaIonships(•  E:(transiIons(between(states(triggered(by(events(

•  Two(categories(of(transiIons(•  ApplicaIonQindependent(•  ApplicaIonQdependent(

**

Page 11: Systematic Testing for Resource Leaks in Android Applications

GUI(Model(for(APV(

Applica5on(Independent(Transi5ons(

Page 12: Systematic Testing for Resource Leaks in Android Applications

GUI(Model(for(APV(

Applica5on(Dependent(Transi5ons(

Page 13: Systematic Testing for Resource Leaks in Android Applications

Coverage(Criteria(• ApplicaIonQindependent(cycles(

• Events(defined(by(the(plaVorm,(and(not(specific(to(individual(applicaIons(

• Example:(ROTATE,(HOME,(POWER(• Cycles(with(BACK(transiIons(

• BACK(transiIon:(going(back(to(a(previous(acIvity(• Opportunity(for(forming(a(cycle(

• ApplicaIonQspecific(neutral(operaIons(• Pairs(of(operaIons(that(“neutralize”(each(other(• Example:(zoomQin(followed(by(zoomQout(

Page 14: Systematic Testing for Resource Leaks in Android Applications

Example(of(a(Generated(Test(Case(

Page 15: Systematic Testing for Resource Leaks in Android Applications

Example(of(a(Generated(Test(Case(

n1 (n2 n3)k

BACK

Page 16: Systematic Testing for Resource Leaks in Android Applications

GUI(Model(for(APV(

Page 17: Systematic Testing for Resource Leaks in Android Applications

GUI(Model(for(APV(

Page 18: Systematic Testing for Resource Leaks in Android Applications

Example(of(a(Generated(Test(Case(

Page 19: Systematic Testing for Resource Leaks in Android Applications

Example(of(a(Generated(Test(Case(

Page 20: Systematic Testing for Resource Leaks in Android Applications

Example(of(a(Generated(Test(Case(

Page 21: Systematic Testing for Resource Leaks in Android Applications

Example(of(a(Generated(Test(Case(

Page 22: Systematic Testing for Resource Leaks in Android Applications

Example(of(a(Generated(Test(Case(

Page 23: Systematic Testing for Resource Leaks in Android Applications

Approach(●  Generate(automaIcally(test(cases(based(on(the(GUI(model,(and(the(targeted(coverage(criteria(●  Followed(by(manual(steps,(e.g.,(to(provide(a(PDF(file(to(be(opened,(and(to(place(it(at(posiIon(3(of(the(file(list(

●  Collect(resource(usage(measurements(as(the(tests(are(being(executed(●  Examples:(managed(heap(size,(naIve(heap(size,(binders,(threads(

●  Drop(“nonQpromising”(cases(for(shorter(execuIon(Ime(●  Report(crashing(execuIons(for(possible(resource(leaks(

**

Page 24: Systematic Testing for Resource Leaks in Android Applications

Experimental(Studies(●  8(openQsource(Android(applicaIons(●  The(generated(test(cases(exposed(18(resource(leak(defects((12(newlyQdiscovered)(●  InvesIgated(manually(the(crashing(test(cases(to(determine(their(root(causes(

●  Detailed(case(studies(to(understand(diversified(causes(of(resource(leaks(●  TradiIonal(leaks((e.g.,(container(leak)(●  Leaking(AndroidQspecific(objects((e.g.,(database(cursors,(binders,(bitmaps)(

●  Leaks(caused(by(naIve(code((e.g.,(improper(management(of(naIve(memory,(hang(in(naIve(code)(**

Page 25: Systematic Testing for Resource Leaks in Android Applications

Conclusions(●  Resource(leaks(are(an(important(problem(for(Android(

●  ModelQbased(test(generaIon(focusing(on(neutral(cycles(is(effecIve(in(detecIng(resource(leaks(

●  Future(work(●  Automated(debugging(of(uncovered(leaks,(using(heap(analysis(

●  Automated(GUI(model(construcIon((iniIal(work(to(appear(at(CGO(2014)(

●  Program(analysis(to(detect(and(diagnose(leaks(staIcally(●  So5ware(release(

●  hfp://www.cse.ohioQstate.edu/presto/so5ware/(**

Page 26: Systematic Testing for Resource Leaks in Android Applications

((

(((((((((((((((((Thank((you(

**