LeakPair: Proactive Repairing of Leaks in Single Page Web Applications

Dongsun Kim
Dongsun KimResearch Associate
LeakPair: Proactive Repairing of
Leaks in Single Page Web Applications
Arooba Shahoor
Kyungpook National University, Korea
Askar Yeltayuly Khamit
UNIST, Korea
Jooyong Yi
UNIST, Korea
Dongsun Kim
Kyungpook National University, Korea
The 38th IEEE/ACM International Conference on Automated Software Engineering (ASE 2023)
14 September 2023
with ACM Distinguished Paper Award
2
LeakPair: Proactive Repairing of Leaks in Single Page Web Applications
4
MOTIVATION
Why Are Memory
Leaks Critical in the
SPA Architecture?
5
Client
Page switching with reload
User Interface
Page 1
Page 2
Page 3
HTTP Request for
initial page load
HTTP Request for
page transition
Server
<template>
Presentation Layer
Database &
Business Logic
Multi Page Application Architecture
6
New page for each request
Inside the Heap
Object 3
Object 2
Object 4
Object 1
Allocated objects from
previous page all wiped off
On user interactions
Client
No reload required
SPA Framework
(Angular/React/Vue..)
Single .html file
<template 1>
<template 2>
<template 3>
View switching without
reload
User Interface
View 1
View 2
View 3
HTTP Request
for initial page
load
AJAX Request for
page transition
Server
Single Page Application Architecture
7
Database &
Business
Logic
Object 3
Object 4
Object 2
Object 1
Object 6
Object 5 This page is never refreshed…
On user interactions
Inside the Heap
Unintentional references
will keep piling up!
Object 7
Object 8
Object 9
JavaScript Devs Can’t Rely on Garbage
Collectors
Garbage Collection in JS (Mark and Sweep)
Reachability from Root
Object 4
Object 5
Object 2
Object 8
Object 6
Object 7
Object 3
Object 1
View 1 (Inside Heap)
window
(GC ROOT 1)
String
(GC ROOT 2)
Garbage Collection in JS (Mark and Sweep)
Reachability from Root
Object 4
Object 5
Object 2
Object 8
UNUSED
Object 7
UNUSED
Object 1
View 2 (Inside Heap)
UNUSED
UNUSED
window
(GC ROOT 1)
String
(GC ROOT 2)
Garbage Collection in JS (Mark and Sweep)
Reachability from Root
UNUSED
MARK
Object 5
MARK
Object 2
MARK
UNUSED
MARK
UNUSED
MARK
Object 7
SWEEP
UNUSED
MARK
Object 1
MARK
View 2 (Inside Heap)
Unused objects marked as alive
and will not be GC’ed, due to
reachability from GC root
window
(GC ROOT 1)
String
(GC ROOT 2)
Garbage Collection in JS (Mark and Sweep)
Reachability from Root
UNUSED
MARK
Object 5
MARK
Object 2
MARK
UNUSED
MARK
UNUSED
MARK
UNUSED
MARK
Object 1
MARK
View 2 (Inside Heap)
window
(GC ROOT 1)
String
(GC ROOT 2)
Garbage Collection in JS (Mark and Sweep)
Reachability from Root
UNUSED
Object 5
Object 2
UNUSED
UNUSED
UNUSED
Object 1
View 3 (Inside Heap)
window
(GC ROOT 1)
String
(GC ROOT 2)
New
object 1
New
object 2
Lingering unwanted objects will
keep gobbling up available space
for newer objects
New
object 3
14
Case in Point
Memory Leak in MS Rooster [2]
Reachable from root
The fix
Leak Detection in JS
Automation Efforts (2015-2022)
2015. MemInsight [3] Reports stale objects, by
computing object lifetimes.
2016. LeakSpot [4] Reports all allocation and
reference sites of leaked objects.
2018. Bleak [5] Identifies and reports leaked
objects by running the website in a headless
browser.
2022. Memlab [7] Reports retainer traces of leaked
objects by running the website in a headless
browser.
15
MemInsight
LeakSpot
Bleak
Memlab
The Problem With Automated Detection Tools
16
Based on staleness criteria + report leak-related
data rather than actual leak locations
Bleak Takes at least 10 mins to execute
Memlab Reported retainer traces contain metadata and internal
objects, making root cause detection arduous
Require manually-written scenario file
State of the Art
● Manual diagnosis via heap snapshots
● Three snapshot technique
● First introduced by Gmail team in 2012
● Detecting root cause can be laborious and inaccurate
17
A change of
perspective
18
What we need is…
APPROACH
19
Proactive
strategy
● Patches that are simple,
non-intrusive and recurring.
● Enable repairs before fault
localization.
● Avoiding detection step is a
huge advantage.
Based on fix patterns [1].
20
[1] D. Kim, J. Nam, J. Song, and S. Kim, “Automatic Patch Generation Learned from
Human-written Patches,” in Proceedings of the 2013 International Conference on Software
Engineering, in ICSE ’13. Piscataway, NJ, USA: IEEE Press, 2013, pp. 802–811.
Leak Pattern Mining
● Search targets: GitHub and Stack Overflow.
● Reported at least 5 times.
● Acknowledged by at least 2 developers.
● Replicable and testable.
21
Fix Pattern Mining
● Stack Overflow answers accepted in at
least 2 posts.
● GitHub commits merged in at least 2
projects.
● Verified by comparing memory footprints
before and after.
22
4 Leaks and
(Corresponding) Fix
Patterns
23
1. Uncleared Timing Events (setTimeout and setInterval)
{
…
setTimeOut(() => {...})
…
}
{
…
setTimeOut(() => {...})
timeOutID = setTimeOut(() => {...})
...
destructorMethodDeclaration() {
...
clearTimeOut(timeOutID)
}
}
If component unmounts before time, these events will still execute,
retaining references of all enclosing objects.
Fix Pattern
Leak Pattern
Other leak patterns
2. Unreleased subscription
3. Unremoved event listener
4. Uncanceled animation frame request
24
Applying Fix Patterns
SPA project Identify JS file(s) Transform to AST Find leak pattern
matches
Match
found?
Apply fix to
AST
Yes
Convert back
to source
EVALUATION
26
Research Questions
RQ1. Effectiveness How effective is the tool at
minimizing memory leaks?
RQ2. Acceptance How useful are generated patches,
as perceived by developers?
RQ3. Correctness What is the impact of our tool on
test suite execution results?
27
Subjects
Known leaks Leaks already detected and fixed by developers.
Unknown leaks Leaks developers were not aware of.
10 open source SPA projects with already known
memory leaks: Microsoft’s Rooster, Fundamental Library for
Angular, Material UI…
10 projects with unfound leaks at the time of
evaluation: Angular Extentions Elements,
react-multi-carousel, ngx-bootstrap…
28
29
Effectiveness Evaluation (RQ 1)
Compare before and after footprints
Execute Memlab
(10 Iterations)
Note memory
footprints
SPA subject
LEAKPAIR
Execute LeakPair
Run the SPA
Subject
Scenario file
(10 Loops)
Note memory
footprints again
30
Effectiveness Evaluation (RQ 1)
Compare before and after footprints
Execute Memlab
(10 Iterations)
Note memory
footprints
SPA subject
LEAKPAIR
Execute LeakPair
Run the SPA
Subject
Scenario file
(10 Loops)
Note memory
footprints again
Compare before
and after footprints
31
Acceptance Evaluation (RQ 2)
Is heap size or
leak count
reduced? Yes
Is unknown
leak?
Yes
Submit fix as PR Track PR status
32
Correctness Evaluation (RQ 3)
Execute test suite
(If available)
SPA subject
LEAKPAIR
Execute LeakPair
Run the SPA
Subject
Note build/
compile time
Note passing/failing
test cases
Note build/compile
time and test case
results again
Compare before and after test cases results and execution times
RESULTS
33
Effectiveness (RQ 1)
● 8 of 10 subjects with known leaks had
noticeable heap reductions.
● 7 of 10 subjects with unknown leaks had
significant heap reductions (4 -18%).
● All subjects had memory leak reductions.
34
LeakPair patches can successfully
prevent leaks and reduce heap,
without leak detection.
Acceptance (RQ 2)
● Total = 20 pull requests
● Agreed = 12 (60%)
Merged Approved Improved Ignored
9 2 1 8
35
LeakPair patches are acceptable to
developers, with more than half of
patch suggestions being accepted.
Correctness (RQ 3)
● Successful build/compilation
● Count of passing/failing test cases of
10 of 10 unchanged
● Execution times before and after LP
execution shared the same range for
all 10 projects
36
LeakPair patches are non-intrusive;
they neither break functionality, nor
incur execution time delays.
Summary
37
1 of 37

Recommended

Functional Reactive Programming on Android by
Functional Reactive Programming on AndroidFunctional Reactive Programming on Android
Functional Reactive Programming on AndroidSam Lee
6.2K views57 slides
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV) by
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)JiandSon
1.5K views66 slides
Kandroid for nhn_deview_20131013_v5_final by
Kandroid for nhn_deview_20131013_v5_finalKandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalNAVER D2
2.9K views52 slides
Testing Vue Apps with Cypress.io (STLJS Meetup April 2018) by
Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)
Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)Christian Catalan
1.2K views100 slides
Android Jetpack + Coroutines: To infinity and beyond by
Android Jetpack + Coroutines: To infinity and beyondAndroid Jetpack + Coroutines: To infinity and beyond
Android Jetpack + Coroutines: To infinity and beyondRamon Ribeiro Rabello
2.1K views82 slides
The curious Life of JavaScript - Talk at SI-SE 2015 by
The curious Life of JavaScript - Talk at SI-SE 2015The curious Life of JavaScript - Talk at SI-SE 2015
The curious Life of JavaScript - Talk at SI-SE 2015jbandi
3K views84 slides

More Related Content

Similar to LeakPair: Proactive Repairing of Leaks in Single Page Web Applications

Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript by
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptJohn Stevenson
1.1K views91 slides
Practicing at the Cutting Edge: Learning and Unlearning about Java Performance by
Practicing at the Cutting Edge: Learning and Unlearning about Java PerformancePracticing at the Cutting Edge: Learning and Unlearning about Java Performance
Practicing at the Cutting Edge: Learning and Unlearning about Java PerformanceC4Media
1.1K views177 slides
NGRX Apps in Depth by
NGRX Apps in DepthNGRX Apps in Depth
NGRX Apps in DepthTrayan Iliev
1.2K views61 slides
W3C HTML5 KIG-How to write low garbage real-time javascript by
W3C HTML5 KIG-How to write low garbage real-time javascriptW3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-How to write low garbage real-time javascriptChanghwan Yi
872 views15 slides
Cross-platform UI Engines Rendering Performance by
Cross-platform UI Engines Rendering PerformanceCross-platform UI Engines Rendering Performance
Cross-platform UI Engines Rendering PerformanceIgalia
36 views52 slides
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023 by
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023Nicolas HAAN
19 views55 slides

Similar to LeakPair: Proactive Repairing of Leaks in Single Page Web Applications(20)

Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript by John Stevenson
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
John Stevenson1.1K views
Practicing at the Cutting Edge: Learning and Unlearning about Java Performance by C4Media
Practicing at the Cutting Edge: Learning and Unlearning about Java PerformancePracticing at the Cutting Edge: Learning and Unlearning about Java Performance
Practicing at the Cutting Edge: Learning and Unlearning about Java Performance
C4Media1.1K views
NGRX Apps in Depth by Trayan Iliev
NGRX Apps in DepthNGRX Apps in Depth
NGRX Apps in Depth
Trayan Iliev1.2K views
W3C HTML5 KIG-How to write low garbage real-time javascript by Changhwan Yi
W3C HTML5 KIG-How to write low garbage real-time javascriptW3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-How to write low garbage real-time javascript
Changhwan Yi872 views
Cross-platform UI Engines Rendering Performance by Igalia
Cross-platform UI Engines Rendering PerformanceCross-platform UI Engines Rendering Performance
Cross-platform UI Engines Rendering Performance
Igalia36 views
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023 by Nicolas HAAN
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
Nicolas HAAN19 views
Apache Beam (incubating) by Apache Apex
Apache Beam (incubating)Apache Beam (incubating)
Apache Beam (incubating)
Apache Apex762 views
Java 7 - New Features - by Mihail Stoynov and Svetlin Nakov by Svetlin Nakov
Java 7 - New Features - by Mihail Stoynov and Svetlin NakovJava 7 - New Features - by Mihail Stoynov and Svetlin Nakov
Java 7 - New Features - by Mihail Stoynov and Svetlin Nakov
Svetlin Nakov2.3K views
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016 by Trayan Iliev
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016
Trayan Iliev985 views
Hierarchical free monads and software design in fp by Alexander Granin
Hierarchical free monads and software design in fpHierarchical free monads and software design in fp
Hierarchical free monads and software design in fp
Alexander Granin161 views
Reactive Microservices with Spring 5: WebFlux by Trayan Iliev
Reactive Microservices with Spring 5: WebFlux Reactive Microservices with Spring 5: WebFlux
Reactive Microservices with Spring 5: WebFlux
Trayan Iliev3.5K views
Advanced Production Debugging by Takipi
Advanced Production DebuggingAdvanced Production Debugging
Advanced Production Debugging
Takipi135.6K views
React Native custom components by Jeremy Grancher
React Native custom componentsReact Native custom components
React Native custom components
Jeremy Grancher5.3K views
The Possibilities and Pitfalls of Writing Your Own State Stores with Daan Gertis by HostedbyConfluent
The Possibilities and Pitfalls of Writing Your Own State Stores with Daan GertisThe Possibilities and Pitfalls of Writing Your Own State Stores with Daan Gertis
The Possibilities and Pitfalls of Writing Your Own State Stores with Daan Gertis
HostedbyConfluent220 views
Android App Architecture with modern libs in practice. Our way in R.I.D., Ser... by Sigma Software
Android App Architecture with modern libs in practice. Our way in R.I.D., Ser...Android App Architecture with modern libs in practice. Our way in R.I.D., Ser...
Android App Architecture with modern libs in practice. Our way in R.I.D., Ser...
Sigma Software218 views
Docker & ECS: Secure Nearline Execution by Brennan Saeta
Docker & ECS: Secure Nearline ExecutionDocker & ECS: Secure Nearline Execution
Docker & ECS: Secure Nearline Execution
Brennan Saeta444 views

More from Dongsun Kim

iFixR: Bug Report Driven Program Repair by
iFixR: Bug Report Driven Program RepairiFixR: Bug Report Driven Program Repair
iFixR: Bug Report Driven Program RepairDongsun Kim
554 views35 slides
TBar: Revisiting Template-based Automated Program Repair by
TBar: Revisiting Template-based Automated Program RepairTBar: Revisiting Template-based Automated Program Repair
TBar: Revisiting Template-based Automated Program RepairDongsun Kim
379 views26 slides
Mining Fix Patterns for FindBugs Violations by
Mining Fix Patterns for FindBugs ViolationsMining Fix Patterns for FindBugs Violations
Mining Fix Patterns for FindBugs ViolationsDongsun Kim
641 views59 slides
Learning to Spot and Refactor Inconsistent Method Names by
Learning to Spot and Refactor Inconsistent Method NamesLearning to Spot and Refactor Inconsistent Method Names
Learning to Spot and Refactor Inconsistent Method NamesDongsun Kim
497 views114 slides
You Cannot Fix What You Cannot Find! --- An Investigation of Fault Localizati... by
You Cannot Fix What You Cannot Find! --- An Investigation of Fault Localizati...You Cannot Fix What You Cannot Find! --- An Investigation of Fault Localizati...
You Cannot Fix What You Cannot Find! --- An Investigation of Fault Localizati...Dongsun Kim
529 views29 slides
A Closer Look at Real-World Patches by
A Closer Look at Real-World PatchesA Closer Look at Real-World Patches
A Closer Look at Real-World PatchesDongsun Kim
425 views26 slides

More from Dongsun Kim(14)

iFixR: Bug Report Driven Program Repair by Dongsun Kim
iFixR: Bug Report Driven Program RepairiFixR: Bug Report Driven Program Repair
iFixR: Bug Report Driven Program Repair
Dongsun Kim554 views
TBar: Revisiting Template-based Automated Program Repair by Dongsun Kim
TBar: Revisiting Template-based Automated Program RepairTBar: Revisiting Template-based Automated Program Repair
TBar: Revisiting Template-based Automated Program Repair
Dongsun Kim379 views
Mining Fix Patterns for FindBugs Violations by Dongsun Kim
Mining Fix Patterns for FindBugs ViolationsMining Fix Patterns for FindBugs Violations
Mining Fix Patterns for FindBugs Violations
Dongsun Kim641 views
Learning to Spot and Refactor Inconsistent Method Names by Dongsun Kim
Learning to Spot and Refactor Inconsistent Method NamesLearning to Spot and Refactor Inconsistent Method Names
Learning to Spot and Refactor Inconsistent Method Names
Dongsun Kim497 views
You Cannot Fix What You Cannot Find! --- An Investigation of Fault Localizati... by Dongsun Kim
You Cannot Fix What You Cannot Find! --- An Investigation of Fault Localizati...You Cannot Fix What You Cannot Find! --- An Investigation of Fault Localizati...
You Cannot Fix What You Cannot Find! --- An Investigation of Fault Localizati...
Dongsun Kim529 views
A Closer Look at Real-World Patches by Dongsun Kim
A Closer Look at Real-World PatchesA Closer Look at Real-World Patches
A Closer Look at Real-World Patches
Dongsun Kim425 views
LSRepair: Live Search of Fix Ingredients for Automated Program Repair by Dongsun Kim
LSRepair: Live Search of Fix Ingredients for Automated Program RepairLSRepair: Live Search of Fix Ingredients for Automated Program Repair
LSRepair: Live Search of Fix Ingredients for Automated Program Repair
Dongsun Kim463 views
AVATAR : Fixing Semantic Bugs with Fix Patterns of Static Analysis Violations by Dongsun Kim
AVATAR : Fixing Semantic Bugs with Fix Patterns of Static Analysis ViolationsAVATAR : Fixing Semantic Bugs with Fix Patterns of Static Analysis Violations
AVATAR : Fixing Semantic Bugs with Fix Patterns of Static Analysis Violations
Dongsun Kim468 views
Bench4BL: Reproducibility Study on the Performance of IR-Based Bug Localization by Dongsun Kim
Bench4BL: Reproducibility Study on the Performance of IR-Based Bug LocalizationBench4BL: Reproducibility Study on the Performance of IR-Based Bug Localization
Bench4BL: Reproducibility Study on the Performance of IR-Based Bug Localization
Dongsun Kim783 views
Impact of Tool Support in Patch Construction by Dongsun Kim
Impact of Tool Support in Patch ConstructionImpact of Tool Support in Patch Construction
Impact of Tool Support in Patch Construction
Dongsun Kim589 views
FaCoY – A Code-to-Code Search Engine by Dongsun Kim
FaCoY – A Code-to-Code Search EngineFaCoY – A Code-to-Code Search Engine
FaCoY – A Code-to-Code Search Engine
Dongsun Kim1.3K views
Augmenting and structuring user queries to support efficient free-form code s... by Dongsun Kim
Augmenting and structuring user queries to support efficient free-form code s...Augmenting and structuring user queries to support efficient free-form code s...
Augmenting and structuring user queries to support efficient free-form code s...
Dongsun Kim658 views
Good Hunting: Locating, Prioritizing, and Fixing Bugs Automatically (Keynote,... by Dongsun Kim
Good Hunting: Locating, Prioritizing, and Fixing Bugs Automatically (Keynote,...Good Hunting: Locating, Prioritizing, and Fixing Bugs Automatically (Keynote,...
Good Hunting: Locating, Prioritizing, and Fixing Bugs Automatically (Keynote,...
Dongsun Kim1.1K views
Automatic Patch Generation Learned from Human-Written Patches by Dongsun Kim
Automatic Patch Generation Learned from Human-Written PatchesAutomatic Patch Generation Learned from Human-Written Patches
Automatic Patch Generation Learned from Human-Written Patches
Dongsun Kim731 views

Recently uploaded

predicting-m3-devopsconMunich-2023-v2.pptx by
predicting-m3-devopsconMunich-2023-v2.pptxpredicting-m3-devopsconMunich-2023-v2.pptx
predicting-m3-devopsconMunich-2023-v2.pptxTier1 app
9 views33 slides
DRYiCE™ iAutomate: AI-enhanced Intelligent Runbook Automation by
DRYiCE™ iAutomate: AI-enhanced Intelligent Runbook AutomationDRYiCE™ iAutomate: AI-enhanced Intelligent Runbook Automation
DRYiCE™ iAutomate: AI-enhanced Intelligent Runbook AutomationHCLSoftware
6 views8 slides
Quality Engineer: A Day in the Life by
Quality Engineer: A Day in the LifeQuality Engineer: A Day in the Life
Quality Engineer: A Day in the LifeJohn Valentino
7 views18 slides
ShortStory_qlora.pptx by
ShortStory_qlora.pptxShortStory_qlora.pptx
ShortStory_qlora.pptxpranathikrishna22
5 views10 slides
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI... by
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...Marc Müller
42 views83 slides
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports by
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug ReportsBushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug ReportsRa'Fat Al-Msie'deen
8 views49 slides

Recently uploaded(20)

predicting-m3-devopsconMunich-2023-v2.pptx by Tier1 app
predicting-m3-devopsconMunich-2023-v2.pptxpredicting-m3-devopsconMunich-2023-v2.pptx
predicting-m3-devopsconMunich-2023-v2.pptx
Tier1 app9 views
DRYiCE™ iAutomate: AI-enhanced Intelligent Runbook Automation by HCLSoftware
DRYiCE™ iAutomate: AI-enhanced Intelligent Runbook AutomationDRYiCE™ iAutomate: AI-enhanced Intelligent Runbook Automation
DRYiCE™ iAutomate: AI-enhanced Intelligent Runbook Automation
HCLSoftware6 views
Quality Engineer: A Day in the Life by John Valentino
Quality Engineer: A Day in the LifeQuality Engineer: A Day in the Life
Quality Engineer: A Day in the Life
John Valentino7 views
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI... by Marc Müller
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Marc Müller42 views
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports by Ra'Fat Al-Msie'deen
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug ReportsBushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated... by TomHalpin9
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...
TomHalpin96 views
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium... by Lisi Hocke
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Lisi Hocke35 views
Dapr Unleashed: Accelerating Microservice Development by Miroslav Janeski
Dapr Unleashed: Accelerating Microservice DevelopmentDapr Unleashed: Accelerating Microservice Development
Dapr Unleashed: Accelerating Microservice Development
Miroslav Janeski12 views
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra... by Marc Müller
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra....NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
Marc Müller41 views
Unlocking the Power of AI in Product Management - A Comprehensive Guide for P... by NimaTorabi2
Unlocking the Power of AI in Product Management - A Comprehensive Guide for P...Unlocking the Power of AI in Product Management - A Comprehensive Guide for P...
Unlocking the Power of AI in Product Management - A Comprehensive Guide for P...
NimaTorabi215 views
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with... by sparkfabrik
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
sparkfabrik8 views

LeakPair: Proactive Repairing of Leaks in Single Page Web Applications

  • 1. LeakPair: Proactive Repairing of Leaks in Single Page Web Applications Arooba Shahoor Kyungpook National University, Korea Askar Yeltayuly Khamit UNIST, Korea Jooyong Yi UNIST, Korea Dongsun Kim Kyungpook National University, Korea The 38th IEEE/ACM International Conference on Automated Software Engineering (ASE 2023) 14 September 2023 with ACM Distinguished Paper Award
  • 2. 2
  • 5. Why Are Memory Leaks Critical in the SPA Architecture? 5
  • 6. Client Page switching with reload User Interface Page 1 Page 2 Page 3 HTTP Request for initial page load HTTP Request for page transition Server <template> Presentation Layer Database & Business Logic Multi Page Application Architecture 6 New page for each request Inside the Heap Object 3 Object 2 Object 4 Object 1 Allocated objects from previous page all wiped off On user interactions
  • 7. Client No reload required SPA Framework (Angular/React/Vue..) Single .html file <template 1> <template 2> <template 3> View switching without reload User Interface View 1 View 2 View 3 HTTP Request for initial page load AJAX Request for page transition Server Single Page Application Architecture 7 Database & Business Logic Object 3 Object 4 Object 2 Object 1 Object 6 Object 5 This page is never refreshed… On user interactions Inside the Heap Unintentional references will keep piling up! Object 7 Object 8 Object 9
  • 8. JavaScript Devs Can’t Rely on Garbage Collectors
  • 9. Garbage Collection in JS (Mark and Sweep) Reachability from Root Object 4 Object 5 Object 2 Object 8 Object 6 Object 7 Object 3 Object 1 View 1 (Inside Heap) window (GC ROOT 1) String (GC ROOT 2)
  • 10. Garbage Collection in JS (Mark and Sweep) Reachability from Root Object 4 Object 5 Object 2 Object 8 UNUSED Object 7 UNUSED Object 1 View 2 (Inside Heap) UNUSED UNUSED window (GC ROOT 1) String (GC ROOT 2)
  • 11. Garbage Collection in JS (Mark and Sweep) Reachability from Root UNUSED MARK Object 5 MARK Object 2 MARK UNUSED MARK UNUSED MARK Object 7 SWEEP UNUSED MARK Object 1 MARK View 2 (Inside Heap) Unused objects marked as alive and will not be GC’ed, due to reachability from GC root window (GC ROOT 1) String (GC ROOT 2)
  • 12. Garbage Collection in JS (Mark and Sweep) Reachability from Root UNUSED MARK Object 5 MARK Object 2 MARK UNUSED MARK UNUSED MARK UNUSED MARK Object 1 MARK View 2 (Inside Heap) window (GC ROOT 1) String (GC ROOT 2)
  • 13. Garbage Collection in JS (Mark and Sweep) Reachability from Root UNUSED Object 5 Object 2 UNUSED UNUSED UNUSED Object 1 View 3 (Inside Heap) window (GC ROOT 1) String (GC ROOT 2) New object 1 New object 2 Lingering unwanted objects will keep gobbling up available space for newer objects New object 3
  • 14. 14 Case in Point Memory Leak in MS Rooster [2] Reachable from root The fix
  • 15. Leak Detection in JS Automation Efforts (2015-2022) 2015. MemInsight [3] Reports stale objects, by computing object lifetimes. 2016. LeakSpot [4] Reports all allocation and reference sites of leaked objects. 2018. Bleak [5] Identifies and reports leaked objects by running the website in a headless browser. 2022. Memlab [7] Reports retainer traces of leaked objects by running the website in a headless browser. 15
  • 16. MemInsight LeakSpot Bleak Memlab The Problem With Automated Detection Tools 16 Based on staleness criteria + report leak-related data rather than actual leak locations Bleak Takes at least 10 mins to execute Memlab Reported retainer traces contain metadata and internal objects, making root cause detection arduous Require manually-written scenario file
  • 17. State of the Art ● Manual diagnosis via heap snapshots ● Three snapshot technique ● First introduced by Gmail team in 2012 ● Detecting root cause can be laborious and inaccurate 17
  • 20. Proactive strategy ● Patches that are simple, non-intrusive and recurring. ● Enable repairs before fault localization. ● Avoiding detection step is a huge advantage. Based on fix patterns [1]. 20 [1] D. Kim, J. Nam, J. Song, and S. Kim, “Automatic Patch Generation Learned from Human-written Patches,” in Proceedings of the 2013 International Conference on Software Engineering, in ICSE ’13. Piscataway, NJ, USA: IEEE Press, 2013, pp. 802–811.
  • 21. Leak Pattern Mining ● Search targets: GitHub and Stack Overflow. ● Reported at least 5 times. ● Acknowledged by at least 2 developers. ● Replicable and testable. 21
  • 22. Fix Pattern Mining ● Stack Overflow answers accepted in at least 2 posts. ● GitHub commits merged in at least 2 projects. ● Verified by comparing memory footprints before and after. 22
  • 23. 4 Leaks and (Corresponding) Fix Patterns 23
  • 24. 1. Uncleared Timing Events (setTimeout and setInterval) { … setTimeOut(() => {...}) … } { … setTimeOut(() => {...}) timeOutID = setTimeOut(() => {...}) ... destructorMethodDeclaration() { ... clearTimeOut(timeOutID) } } If component unmounts before time, these events will still execute, retaining references of all enclosing objects. Fix Pattern Leak Pattern Other leak patterns 2. Unreleased subscription 3. Unremoved event listener 4. Uncanceled animation frame request 24
  • 25. Applying Fix Patterns SPA project Identify JS file(s) Transform to AST Find leak pattern matches Match found? Apply fix to AST Yes Convert back to source
  • 27. Research Questions RQ1. Effectiveness How effective is the tool at minimizing memory leaks? RQ2. Acceptance How useful are generated patches, as perceived by developers? RQ3. Correctness What is the impact of our tool on test suite execution results? 27
  • 28. Subjects Known leaks Leaks already detected and fixed by developers. Unknown leaks Leaks developers were not aware of. 10 open source SPA projects with already known memory leaks: Microsoft’s Rooster, Fundamental Library for Angular, Material UI… 10 projects with unfound leaks at the time of evaluation: Angular Extentions Elements, react-multi-carousel, ngx-bootstrap… 28
  • 29. 29 Effectiveness Evaluation (RQ 1) Compare before and after footprints Execute Memlab (10 Iterations) Note memory footprints SPA subject LEAKPAIR Execute LeakPair Run the SPA Subject Scenario file (10 Loops) Note memory footprints again
  • 30. 30 Effectiveness Evaluation (RQ 1) Compare before and after footprints Execute Memlab (10 Iterations) Note memory footprints SPA subject LEAKPAIR Execute LeakPair Run the SPA Subject Scenario file (10 Loops) Note memory footprints again
  • 31. Compare before and after footprints 31 Acceptance Evaluation (RQ 2) Is heap size or leak count reduced? Yes Is unknown leak? Yes Submit fix as PR Track PR status
  • 32. 32 Correctness Evaluation (RQ 3) Execute test suite (If available) SPA subject LEAKPAIR Execute LeakPair Run the SPA Subject Note build/ compile time Note passing/failing test cases Note build/compile time and test case results again Compare before and after test cases results and execution times
  • 34. Effectiveness (RQ 1) ● 8 of 10 subjects with known leaks had noticeable heap reductions. ● 7 of 10 subjects with unknown leaks had significant heap reductions (4 -18%). ● All subjects had memory leak reductions. 34 LeakPair patches can successfully prevent leaks and reduce heap, without leak detection.
  • 35. Acceptance (RQ 2) ● Total = 20 pull requests ● Agreed = 12 (60%) Merged Approved Improved Ignored 9 2 1 8 35 LeakPair patches are acceptable to developers, with more than half of patch suggestions being accepted.
  • 36. Correctness (RQ 3) ● Successful build/compilation ● Count of passing/failing test cases of 10 of 10 unchanged ● Execution times before and after LP execution shared the same range for all 10 projects 36 LeakPair patches are non-intrusive; they neither break functionality, nor incur execution time delays.