SlideShare a Scribd company logo
1 of 37
Download to read offline
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
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

More Related Content

Similar to Proactive Repairing of Memory Leaks in Single Page Web Apps

Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
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
 
Practicing at the Cutting Edge: Learning and Unlearning about Java Performance
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
 
NGRX Apps in Depth
NGRX Apps in DepthNGRX Apps in Depth
NGRX Apps in DepthTrayan Iliev
 
W3C HTML5 KIG-How to write low garbage real-time javascript
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
 
Cross-platform UI Engines Rendering Performance
Cross-platform UI Engines Rendering PerformanceCross-platform UI Engines Rendering Performance
Cross-platform UI Engines Rendering PerformanceIgalia
 
Comment 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-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
 
Apache Beam (incubating)
Apache Beam (incubating)Apache Beam (incubating)
Apache Beam (incubating)Apache Apex
 
Java 7 - New Features - by Mihail Stoynov and 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 NakovSvetlin Nakov
 
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016
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 2016Trayan Iliev
 
Hierarchical free monads and software design in fp
Hierarchical free monads and software design in fpHierarchical free monads and software design in fp
Hierarchical free monads and software design in fpAlexander Granin
 
Reactive Microservices with Spring 5: WebFlux
Reactive Microservices with Spring 5: WebFlux Reactive Microservices with Spring 5: WebFlux
Reactive Microservices with Spring 5: WebFlux Trayan Iliev
 
Advanced Production Debugging
Advanced Production DebuggingAdvanced Production Debugging
Advanced Production DebuggingTakipi
 
Behavior driven oop
Behavior driven oopBehavior driven oop
Behavior driven oopPiyush Verma
 
React Native custom components
React Native custom componentsReact Native custom components
React Native custom componentsJeremy Grancher
 
Deep dive into Android async operations
Deep dive into Android async operationsDeep dive into Android async operations
Deep dive into Android async operationsMateusz Grzechociński
 
Mobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve MobileMobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve MobileKonstantin Loginov
 
The Possibilities and Pitfalls of Writing Your Own State Stores with Daan Gertis
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 GertisHostedbyConfluent
 
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...
Android App Architecture with modern libs in practice. Our way in R.I.D., Ser...Sigma Software
 
Docker & ECS: Secure Nearline Execution
Docker & ECS: Secure Nearline ExecutionDocker & ECS: Secure Nearline Execution
Docker & ECS: Secure Nearline ExecutionBrennan Saeta
 

Similar to Proactive Repairing of Memory Leaks in Single Page Web Apps (20)

Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
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
 
Practicing at the Cutting Edge: Learning and Unlearning about Java Performance
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
 
NGRX Apps in Depth
NGRX Apps in DepthNGRX Apps in Depth
NGRX Apps in Depth
 
W3C HTML5 KIG-How to write low garbage real-time javascript
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
 
Cross-platform UI Engines Rendering Performance
Cross-platform UI Engines Rendering PerformanceCross-platform UI Engines Rendering Performance
Cross-platform UI Engines Rendering Performance
 
Comment 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-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
 
Apache Beam (incubating)
Apache Beam (incubating)Apache Beam (incubating)
Apache Beam (incubating)
 
Java 7 - New Features - by Mihail Stoynov and 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
 
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016
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
 
Hierarchical free monads and software design in fp
Hierarchical free monads and software design in fpHierarchical free monads and software design in fp
Hierarchical free monads and software design in fp
 
Guides To Analyzing WebKit Performance
Guides To Analyzing WebKit PerformanceGuides To Analyzing WebKit Performance
Guides To Analyzing WebKit Performance
 
Reactive Microservices with Spring 5: WebFlux
Reactive Microservices with Spring 5: WebFlux Reactive Microservices with Spring 5: WebFlux
Reactive Microservices with Spring 5: WebFlux
 
Advanced Production Debugging
Advanced Production DebuggingAdvanced Production Debugging
Advanced Production Debugging
 
Behavior driven oop
Behavior driven oopBehavior driven oop
Behavior driven oop
 
React Native custom components
React Native custom componentsReact Native custom components
React Native custom components
 
Deep dive into Android async operations
Deep dive into Android async operationsDeep dive into Android async operations
Deep dive into Android async operations
 
Mobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve MobileMobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve Mobile
 
The Possibilities and Pitfalls of Writing Your Own State Stores with Daan Gertis
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
 
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...
Android App Architecture with modern libs in practice. Our way in R.I.D., Ser...
 
Docker & ECS: Secure Nearline Execution
Docker & ECS: Secure Nearline ExecutionDocker & ECS: Secure Nearline Execution
Docker & ECS: Secure Nearline Execution
 

More from Dongsun Kim

iFixR: Bug Report Driven Program Repair
iFixR: Bug Report Driven Program RepairiFixR: Bug Report Driven Program Repair
iFixR: Bug Report Driven Program RepairDongsun Kim
 
TBar: Revisiting Template-based Automated Program Repair
TBar: Revisiting Template-based Automated Program RepairTBar: Revisiting Template-based Automated Program Repair
TBar: Revisiting Template-based Automated Program RepairDongsun Kim
 
Mining Fix Patterns for FindBugs Violations
Mining Fix Patterns for FindBugs ViolationsMining Fix Patterns for FindBugs Violations
Mining Fix Patterns for FindBugs ViolationsDongsun Kim
 
Learning to Spot and Refactor Inconsistent Method Names
Learning to Spot and Refactor Inconsistent Method NamesLearning to Spot and Refactor Inconsistent Method Names
Learning to Spot and Refactor Inconsistent Method NamesDongsun 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...
You Cannot Fix What You Cannot Find! --- An Investigation of Fault Localizati...Dongsun Kim
 
A Closer Look at Real-World Patches
A Closer Look at Real-World PatchesA Closer Look at Real-World Patches
A Closer Look at Real-World PatchesDongsun Kim
 
LSRepair: Live Search of Fix Ingredients for Automated Program Repair
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 RepairDongsun Kim
 
AVATAR : Fixing Semantic Bugs with Fix Patterns of Static Analysis Violations
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 ViolationsDongsun Kim
 
Bench4BL: Reproducibility Study on the Performance of IR-Based Bug Localization
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 LocalizationDongsun Kim
 
Impact of Tool Support in Patch Construction
Impact of Tool Support in Patch ConstructionImpact of Tool Support in Patch Construction
Impact of Tool Support in Patch ConstructionDongsun Kim
 
FaCoY – A Code-to-Code Search Engine
FaCoY – A Code-to-Code Search EngineFaCoY – A Code-to-Code Search Engine
FaCoY – A Code-to-Code Search EngineDongsun 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...
Augmenting and structuring user queries to support efficient free-form code s...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,...
Good Hunting: Locating, Prioritizing, and Fixing Bugs Automatically (Keynote,...Dongsun Kim
 
Automatic Patch Generation Learned from Human-Written Patches
Automatic Patch Generation Learned from Human-Written PatchesAutomatic Patch Generation Learned from Human-Written Patches
Automatic Patch Generation Learned from Human-Written PatchesDongsun Kim
 

More from Dongsun Kim (14)

iFixR: Bug Report Driven Program Repair
iFixR: Bug Report Driven Program RepairiFixR: Bug Report Driven Program Repair
iFixR: Bug Report Driven Program Repair
 
TBar: Revisiting Template-based Automated Program Repair
TBar: Revisiting Template-based Automated Program RepairTBar: Revisiting Template-based Automated Program Repair
TBar: Revisiting Template-based Automated Program Repair
 
Mining Fix Patterns for FindBugs Violations
Mining Fix Patterns for FindBugs ViolationsMining Fix Patterns for FindBugs Violations
Mining Fix Patterns for FindBugs Violations
 
Learning to Spot and Refactor Inconsistent Method Names
Learning to Spot and Refactor Inconsistent Method NamesLearning to Spot and Refactor Inconsistent Method Names
Learning to Spot and Refactor Inconsistent Method Names
 
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...
You Cannot Fix What You Cannot Find! --- An Investigation of Fault Localizati...
 
A Closer Look at Real-World Patches
A Closer Look at Real-World PatchesA Closer Look at Real-World Patches
A Closer Look at Real-World Patches
 
LSRepair: Live Search of Fix Ingredients for Automated Program Repair
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
 
AVATAR : Fixing Semantic Bugs with Fix Patterns of Static Analysis Violations
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
 
Bench4BL: Reproducibility Study on the Performance of IR-Based Bug Localization
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
 
Impact of Tool Support in Patch Construction
Impact of Tool Support in Patch ConstructionImpact of Tool Support in Patch Construction
Impact of Tool Support in Patch Construction
 
FaCoY – A Code-to-Code Search Engine
FaCoY – A Code-to-Code Search EngineFaCoY – A Code-to-Code Search Engine
FaCoY – A Code-to-Code Search Engine
 
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...
Augmenting and structuring user queries to support efficient free-form code s...
 
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,...
Good Hunting: Locating, Prioritizing, and Fixing Bugs Automatically (Keynote,...
 
Automatic Patch Generation Learned from Human-Written Patches
Automatic Patch Generation Learned from Human-Written PatchesAutomatic Patch Generation Learned from Human-Written Patches
Automatic Patch Generation Learned from Human-Written Patches
 

Recently uploaded

Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutionsmonugehlot87
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 

Recently uploaded (20)

Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutions
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 

Proactive Repairing of Memory Leaks in Single Page Web Apps

  • 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
  • 3.
  • 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.