SlideShare a Scribd company logo
1 of 40
Download to read offline
LeakChecker:	
  Prac,cal	
  Sta,c	
  Memory	
  Leak	
  
Detec,on	
  for	
  Managed	
  Languages	
  
Dacong	
  (Tony)	
  Yan1,	
  Guoqing	
  Xu2,	
  Shengqian	
  Yang1,	
  Atanas	
  Rountev1	
  
	
  
1	
  Ohio	
  State	
  University	
  

2	
  University	
  of	
  California,	
  Irvine	
  

	
  

PRESTO:	
  Program	
  Analyses	
  and	
  So5ware	
  Tools	
  Research	
  Group,	
  Ohio	
  State	
  University	
  
Memory	
  Leaks	
  in	
  Managed	
  Languages
	
  
•  Languages	
  such	
  as	
  Java	
  sMll	
  have	
  memory	
  leaks:	
  
unnecessary	
  references	
  keep	
  unused	
  objects	
  alive	
  
•  StaMc	
  leak	
  detecMon	
  

–  Widely	
  used	
  for	
  unmanaged	
  languages	
  such	
  as	
  C	
  
–  Cannot	
  be	
  applied	
  to	
  managed	
  languages:	
  no	
  explicit	
  memory	
  
deallocaMon	
  

•  General	
  definiMon	
  of	
  leaks	
  

–  Precision:	
  difficult	
  to	
  compute	
  object	
  liveness	
  precisely	
  
–  Performance:	
  limited	
  scalability	
  for	
  large	
  programs	
  

•  Our	
  approach	
  

–  Shi5	
  the	
  focus,	
  and	
  idenMfy	
  common	
  leak	
  paVerns	
  

2	
  
Proposed	
  Leak	
  DetecMon	
  for	
  Java
	
  
•  ObservaMon:	
  leaks	
  are	
  o5en	
  related	
  to	
  frequently	
  
occurring	
  events	
  (e.g.,	
  loop	
  iteraMons)	
  
•  SoluMon:	
  focus	
  on	
  a	
  user-­‐specified	
  event	
  loop	
  
•  ObservaMon:	
  a	
  leaking	
  object	
  is	
  o5en	
  
–  created	
  by	
  one	
  loop	
  iteraMon	
  
–  escapes	
  this	
  iteraMon	
  
–  never	
  used	
  in	
  later	
  iteraMons	
  

•  SoluMon:	
  interprocedural	
  tracking	
  of	
  

3	
  

–  whether	
  an	
  object	
  escapes	
  to	
  a	
  memory	
  locaMon	
  outside	
  of	
  
the	
  loop	
  
–  whether	
  an	
  escaping	
  object	
  flows	
  from	
  the	
  outside	
  locaMon	
  
back	
  into	
  a	
  later	
  loop	
  iteraMon	
  
Example
	
  
“main”:!

7 class Transaction {!

1 Transaction t = new Transaction();! 8

Order prev;!

2 for (int i = 0; i < X; ++i) {!

Customer[] custs = new Customer[…];

9

3

t.display();!

10

4

Order order = new Order(...);!

11

Order r = this.prev;!

5

t.process(order);!

12

… // display r!

13

this.prev = null; // remove!

6 }!

void display() {!

!

14

} !

21 class Customer {!

15

void process(Order p) {!

22

Order[] orders = new Order[…];!

16

this.prev = p;!

23

void addOrder(Order q) {!

17

Customer c = this.custs[…];!

18

c.addOrder(p);!

19

... // process p!

24
25

this.orders[...] = q;!
}!

26 }!

20
!

}

}!

An	
  example	
  adapted	
  from	
  SPECjbb2000	
  
!
4	
  
Example
	
  
“main”:!

7 class Transaction {!

1 Transaction t = new Transaction();! 8

Order prev;!

2 for (int i = 0; i < X; ++i) {!

Customer[] custs = new Customer[…];

9

3

t.display();!

10

4

Order order = new Order(...);!

11

Order r = this.prev;!

5

t.process(order);!

12

… // display r!

13

this.prev = null; // remove!

6 }!

void display() {!

!

14

} !

21 class Customer {!

15

void process(Order p) {!

22

Order[] orders = new Order[…];!

16

this.prev = p;!

23

void addOrder(Order q) {!

17

Customer c = this.custs[…];!

18

c.addOrder(p);!

19

... // process p!

24
25

this.orders[...] = q;!
}!

26 }!

20
!

}

}!

An	
  example	
  adapted	
  from	
  SPECjbb2000	
  
!
5	
  
Example
	
  
“main”:!

7 class Transaction {!

1 Transaction t = new Transaction();! 8

Order prev;!

2 for (int i = 0; i < X; ++i) {!

Customer[] custs = new Customer[…];

9

3

t.display();!

10

4

Order order = new Order(...);!

11

Order r = this.prev;!

5

t.process(order);!

12

… // display r!

13

this.prev = null; // remove!

6 }!

loop	
  object	
  

!

void display() {!

14

} !

21 class Customer {!

15

void process(Order p) {!

22

Order[] orders = new Order[…];!

16

this.prev = p;!

23

void addOrder(Order q) {!

17

Customer c = this.custs[…];!

18

c.addOrder(p);!

19

... // process p!

24
25

this.orders[...] = q;!
}!

26 }!
!

20
!

6	
  

}

}!
“main”:!

outside	
  object	
  

Example
	
  
7 class Transaction {!

1 Transaction t = new Transaction();! 8

Order prev;!

2 for (int i = 0; i < X; ++i) {!

Customer[] custs = new Customer[…];

9

3

t.display();!

10

4

Order order = new Order(...);!

11

Order r = this.prev;!

5

t.process(order);!

12

… // display r!

13

this.prev = null; // remove!

6 }!

loop	
  object	
  

!

void display() {!

14

} !

21 class Customer {!

15

void process(Order p) {!

22

Order[] orders = new Order[…];!

16

this.prev = p;!

23

void addOrder(Order q) {!

17

Customer c = this.custs[…];!

18

c.addOrder(p);!

19

... // process p!

24
25

this.orders[...] = q;!
}!

26 }!
!

20
!

7	
  

}

}!
“main”:!

outside	
  object	
  

Example
	
  
7 class Transaction {!

1 Transaction t = new Transaction();! 8

Order prev;!

2 for (int i = 0; i < X; ++i) {!

Customer[] custs = new Customer[…];

9

3

t.display();!

10

4

Order order = new Order(...);!

11

Order r = this.prev;!

5

t.process(order);!

12

… // display r!

13

this.prev = null; // remove!

6 }!

loop	
  object	
  

!

void display() {!

14

} !

21 class Customer {!

15

void process(Order p) {!

22

Order[] orders = new Order[…];!

16

this.prev = p;!

23

void addOrder(Order q) {!

17

Customer c = this.custs[…];!

18

c.addOrder(p);!

19

... // process p!

24
25

this.orders[...] = q;!
}!

26 }!
!

20
!

8	
  

}

}!
“main”:!

outside	
  object	
  

Example
	
  
7 class Transaction {!

1 Transaction t = new Transaction();! 8

Order prev;!

2 for (int i = 0; i < X; ++i) {!

Customer[] custs = new Customer[…];

9

3

t.display();!

10

4

Order order = new Order(...);!

11

Order r = this.prev;!

5

t.process(order);!

12

… // display r!

13

this.prev = null; // remove!

6 }!

loop	
  object	
  

!

void display() {!

14

} !

21 class Customer {!

15

void process(Order p) {!

22

Order[] orders = new Order[…];!

16

this.prev = p;!

23

void addOrder(Order q) {!

17

Customer c = this.custs[…];!

18

c.addOrder(p);!

19

... // process p!

24
25

this.orders[...] = q;!
}!

26 }!
!

20
!

9	
  

}

}!
Example
	
  
“main”:!

7 class Transaction {!

1 Transaction t = new Transaction();! 8

Order prev;!

2 for (int i = 0; i < X; ++i) {!

Customer[] custs = new Customer[…];

9

3

t.display();!

10

4

Order order = new Order(...);!

11

Order r = this.prev;!

5

t.process(order);!

12

… // display r!

13

this.prev = null; // remove!

6 }!

void display() {!

!

14

} !

21 class Customer {!

15

void process(Order p) {!

22

Order[] orders = new Order[…];!

16

this.prev = p;!

23

void addOrder(Order q) {!

17

Customer c = this.custs[…];!

18

c.addOrder(p);!

19

... // process p!

24
25

this.orders[...] = q;!
}!

26 }!
!

20
!

10	
  

}

}!
Example
	
  
“main”:!

7 class Transaction {!

1 Transaction t = new Transaction();! 8

Order prev;!

2 for (int i = 0; i < X; ++i) {!

Customer[] custs = new Customer[…];

9

3

t.display();!

10

4

Order order = new Order(...);!

11

Order r = this.prev;!

5

t.process(order);!

12

… // display r!

13

this.prev = null; // remove!

6 }!

void display() {!

!

14

} !

21 class Customer {!

15

void process(Order p) {!

22

Order[] orders = new Order[…];!

16

this.prev = p;!

23

void addOrder(Order q) {!

17

Customer c = this.custs[…];!

18

c.addOrder(p);!

19

... // process p!

24
25

this.orders[...] = q;!
}!

26 }!
!

20
!

11	
  

}

}!
Example
	
  
“main”:!

7 class Transaction {!

1 Transaction t = new Transaction();! 8

Order prev;!

2 for (int i = 0; i < X; ++i) {!

Customer[] custs = new Customer[…];

9

3

t.display();!

10

4

Order order = new Order(...);!

11

Order r = this.prev;!

5

t.process(order);!

12

… // display r!

13

this.prev = null; // remove!

6 }!

void display() {!

!

14

} !

21 class Customer {!

15

void process(Order p) {!

22

Order[] orders = new Order[…];!

16

23

void addOrder(Order q) {!

17

this.prev = p;! store16	
  
Customer c = this.custs[…];!

18

c.addOrder(p);!

19

... // process p!

24
25

this.orders[...] = q;!
}!

26 }!
!

20
!

12	
  

}

}!
Example
	
  
“main”:!

7 class Transaction {!

1 Transaction t = new Transaction();! 8

Order prev;!

2 for (int i = 0; i < X; ++i) {!

Customer[] custs = new Customer[…];

9

3

t.display();!

10

4

Order order = new Order(...);!

11

Order r = this.prev;!

5

t.process(order);!

12

… // display r!

13

this.prev = null; // remove!

6 }!

void display() {!

!

14

} !

21 class Customer {!

15

void process(Order p) {!

22

Order[] orders = new Order[…];!

16

23

void addOrder(Order q) {!

17

this.prev = p;! store16	
  
Customer c = this.custs[…];!

18

c.addOrder(p);!

19

... // process p!

24
25

this.orders[...] = q;!
}!

26 }!

Order4!

store16	
  

20

Transaction1!
!

!

13	
  

escape	
  

}

}!
Example
	
  
“main”:!

7 class Transaction {!

1 Transaction t = new Transaction();! 8

Order prev;!

2 for (int i = 0; i < X; ++i) {!

Customer[] custs = new Customer[…];

9

3

t.display();!

10

4

Order order = new Order(...);!

11

Order r = this.prev;!

5

t.process(order);!

12

… // display r!

13

this.prev = null; // remove!

6 }!

void display() {!

!

14

} !

21 class Customer {!

15

void process(Order p) {!

22

Order[] orders = new Order[…];!

16

this.prev = p;!

23

void addOrder(Order q) {!

17

Customer c = this.custs[…];!

18

c.addOrder(p);!

19

... // process p!

this.orders[...] = q;! store24	
  

24
25

}!

26 }!
!

20
!

14	
  

}

}!
Example
	
  
“main”:!

7 class Transaction {!

1 Transaction t = new Transaction();! 8

Order prev;!

2 for (int i = 0; i < X; ++i) {!

Customer[] custs = new Customer[…];

9

3

t.display();!

10

4

Order order = new Order(...);!

11

Order r = this.prev;!

5

t.process(order);!

12

… // display r!

13

this.prev = null; // remove!

6 }!

void display() {!

!

14

} !

21 class Customer {!

15

void process(Order p) {!

22

Order[] orders = new Order[…];!

16

this.prev = p;!

23

void addOrder(Order q) {!

17

Customer c = this.custs[…];!

18

c.addOrder(p);!

19

... // process p!

this.orders[...] = q;! store24	
  

24
25

}!

26 }!

Order4!
15	
  

20
store24	
  	
  

Order[]23!

store22	
  	
  

!

Customer?!
!

}

store?	
  	
  

escape	
  

}!

Customer[]10!

store9	
  

Transaction1!
Example
	
  
“main”:!

7 class Transaction {!

1 Transaction t = new Transaction();! 8

Order prev;!

2 for (int i = 0; i < X; ++i) {!

Customer[] custs = new Customer[…];

9

3

t.display();!

10

4

Order order = new Order(...);!

11

Order r = this.prev;!

5

t.process(order);!

12

… // display r!

13

this.prev = null; // remove!

6 }!

void display() {!

!

14

} !

21 class Customer {!

15

void process(Order p) {!

22

Order[] orders = new Order[…];!

16

this.prev = p;!

23

void addOrder(Order q) {!

17

Customer c = this.custs[…];!

18

c.addOrder(p);!

19

... // process p!

24
25

this.orders[...] = q;!
}!

26 }!

!

Order4,i!
16	
  

20

store24/orders,	
  …,	
  store9/custs	
  	
  

store16/prev	
  

}

}!

Transaction1!
!
Example
	
  
“main”:!

7 class Transaction {!

1 Transaction t = new Transaction();! 8

Order prev;!

2 for (int i = 0; i < X; ++i) {!

Customer[] custs = new Customer[…];

9

3

t.display();!

10

4

Order order = new Order(...);!

11

Order r = this.prev;!

5

t.process(order);!

12

… // display r!

13

this.prev = null; // remove!

6 }!

void display() {!

!

14

} !

21 class Customer {!

15

void process(Order p) {!

22

Order[] orders = new Order[…];!

16

this.prev = p;!

23

void addOrder(Order q) {!

17

Customer c = this.custs[…];!

18

c.addOrder(p);!

19

... // process p!

24
25

this.orders[...] = q;!
}!

26 }!

Order4,i!
17	
  

store24/orders,	
  …,	
  store9/custs	
  	
  

20

leaking?	
  
!

}

}!

Transaction1!
!
Example
	
  
“main”:!

7 class Transaction {!

1 Transaction t = new Transaction();! 8

Order prev;!

2 for (int i = 0; i < X; ++i) {!

Customer[] custs = new Customer[…];

9

3

t.display();!

10

4

Order order = new Order(...);!

11

Order r = this.prev;!

5

t.process(order);!

12

… // display r!

13

this.prev = null; // remove!

6 }!

void display() {!

!

14

} !

21 class Customer {!

15

void process(Order p) {!

22

Order[] orders = new Order[…];!

16

this.prev = p;!

23

void addOrder(Order q) {!

17

Customer c = this.custs[…];!

18

c.addOrder(p);!

19

... // process p!

24
25

this.orders[...] = q;!
}!

26 }!

20
!

Order4,i!
18	
  

store16/prev	
  

}

}!

Transaction1!
!

leaking?	
  
Example
	
  
“main”:!

7 class Transaction {!

1 Transaction t = new Transaction();! 8

Order prev;!

2 for (int i = 0; i < X; ++i) {!

Customer[] custs = new Customer[…];

9

3

t.display();!

10

4

Order order = new Order(...);!

11

Order r = this.prev;!

5

t.process(order);!

12

… // display r!

13

this.prev = null; // remove!

6 }!

void display() {!

load11	
  

!

14

} !

21 class Customer {!

15

void process(Order p) {!

22

Order[] orders = new Order[…];!

16

this.prev = p;!

23

void addOrder(Order q) {!

17

Customer c = this.custs[…];!

18

c.addOrder(p);!

19

... // process p!

24
25

this.orders[...] = q;!
}!

26 }!

20
!

Order4,i!
19	
  

store16/prev	
  

}

}!

Transaction1!
!

leaking?	
  
Example
	
  
“main”:!

7 class Transaction {!

1 Transaction t = new Transaction();! 8

Order prev;!

2 for (int i = 0; i < X; ++i) {!

Customer[] custs = new Customer[…];

9

3

t.display();!

10

4

Order order = new Order(...);!

11

Order r = this.prev;!

5

t.process(order);!

12

… // display r!

13

this.prev = null; // remove!

6 }!

void display() {!

load11	
  

!

14

} !

21 class Customer {!

15

void process(Order p) {!

22

Order[] orders = new Order[…];!

16

this.prev = p;!

23

void addOrder(Order q) {!

17

Customer c = this.custs[…];!

18

c.addOrder(p);!

19

... // process p!

24
25

this.orders[...] = q;!
}!

26 }!

20
!

Order4,i!
20	
  

store16/prev	
  

}

}!

Transaction1!
!

leaking?	
  

store16	
  
Example
	
  
“main”:!

7 class Transaction {!

1 Transaction t = new Transaction();! 8

Order prev;!

2 for (int i = 0; i < X; ++i) {!

Customer[] custs = new Customer[…];

9

3

t.display();!

10

4

Order order = new Order(...);!

11

Order r = this.prev;!

5

t.process(order);!

12

… // display r!

13

this.prev = null; // remove!

6 }!

void display() {!

load11	
  

!

14

} !

21 class Customer {!

15

void process(Order p) {!

22

Order[] orders = new Order[…];!

16

this.prev = p;!

23

void addOrder(Order q) {!

17

Customer c = this.custs[…];!

18

c.addOrder(p);!

19

... // process p!

24
25

this.orders[...] = q;!
}!

26 }!

load11/prev	
  

!

Order4,i!
21	
  

20

store16/prev	
  

}

}!

Transaction1!
!

leaking?	
  

store16	
  
Example
	
  
“main”:!

7 class Transaction {!

1 Transaction t = new Transaction();! 8

Order prev;!

2 for (int i = 0; i < X; ++i) {!

Customer[] custs = new Customer[…];

9

3

t.display();!

10

4

Order order = new Order(...);!

11

Order r = this.prev;!

5

t.process(order);!

12

… // display r!

13

this.prev = null; // remove!

6 }!

void display() {!

load11	
  

!

14

} !

21 class Customer {!

15

void process(Order p) {!

22

Order[] orders = new Order[…];!

16

this.prev = p;!

23

void addOrder(Order q) {!

17

Customer c = this.custs[…];!

18

c.addOrder(p);!

19

... // process p!

24
25
26 }!

this.orders[...] = q;!
}!

(i+1)-­‐th	
  itera,on	
   load11/prev	
  
!

Order4,i!
22	
  

i-­‐th	
  itera,on	
  

20

store16/prev	
  

}

}!

Transaction1!
!

leaking?	
  

store16	
  
Example
	
  
“main”:!

7 class Transaction {!

1 Transaction t = new Transaction();! 8

Order prev;!

2 for (int i = 0; i < X; ++i) {!

Customer[] custs = new Customer[…];

9

3

t.display();!

10

4

Order order = new Order(...);!

11

Order r = this.prev;!

5

t.process(order);!

12

… // display r!

13

this.prev = null; // remove!

6 }!

void display() {!

!

14

} !

21 class Customer {!

15

void process(Order p) {!

22

Order[] orders = new Order[…];!

16

this.prev = p;!

23

void addOrder(Order q) {!

17

Customer c = this.custs[…];!

18

c.addOrder(p);!

19

... // process p!

24
25

this.orders[...] = q;!
}!

26 }!

store24/orders,	
  …,	
  store9/custs	
  	
  

Order4,i!
23	
  

store16/prev	
  

20

leaking	
  
!

}

}!

Transaction1!
!

non-­‐leaking	
  
StaMc	
  Analysis	
  Outline
	
  
•  Object:	
  pair	
  of	
  allocaMon	
  site	
  and	
  calling	
  context	
  
•  Flows-­‐out	
  path	
  
–  Loop	
  object	
  escaping	
  to	
  outside	
  object	
  
–  Sequence	
  of	
  store	
  statements	
  for	
  the	
  flow	
  

•  Flows-­‐in	
  path	
  

–  Escaping	
  object	
  flows	
  from	
  outside	
  object	
  into	
  the	
  loop	
  
–  Sequence	
  of	
  load	
  statements	
  causing	
  the	
  flow	
  

•  Loop	
  iteraMon	
  constraints	
  

–  Flows-­‐in	
  valid	
  only	
  if	
  the	
  corresponding	
  Flows-­‐out	
  occurs	
  in	
  
an	
  earlier	
  iteraMon	
  

•  On-­‐demand	
  analysis	
  using	
  context-­‐free	
  language	
  
reachability	
  to	
  match	
  store/load	
  and	
  call/return	
  
24	
  
StaMc	
  Analysis	
  Outline
	
  
•  Object:	
  pair	
  of	
  allocaMon	
  site	
  and	
  calling	
  context	
  
•  Flows-­‐out	
  path	
  
–  Loop	
  object	
  escaping	
  to	
  outside	
  object	
  
–  Sequence	
  of	
  store	
  statements	
  for	
  the	
  flow	
  

•  Flows-­‐in	
  path	
  

–  Escaping	
  object	
  flows	
  from	
  outside	
  object	
  into	
  the	
  loop	
  
–  Sequence	
  of	
  load	
  statements	
  causing	
  the	
  flow	
  

•  Loop	
  iteraMon	
  constraints	
  

–  Flows-­‐in	
  valid	
  only	
  if	
  the	
  corresponding	
  Flows-­‐out	
  occurs	
  in	
  
an	
  earlier	
  iteraMon	
  

•  On-­‐demand	
  analysis	
  using	
  context-­‐free	
  language	
  
reachability	
  to	
  match	
  store/load	
  and	
  call/return	
  
25	
  
StaMc	
  Analysis	
  Outline
	
  
•  Object:	
  pair	
  of	
  allocaMon	
  site	
  and	
  calling	
  context	
  
•  Flows-­‐out	
  path	
  
–  Loop	
  object	
  escaping	
  to	
  outside	
  object	
  
–  Sequence	
  of	
  store	
  statements	
  for	
  the	
  flow	
  

•  Flows-­‐in	
  path	
  

–  Escaping	
  object	
  flows	
  from	
  outside	
  object	
  into	
  the	
  loop	
  
–  Sequence	
  of	
  load	
  statements	
  causing	
  the	
  flow	
  

•  Loop	
  iteraMon	
  constraints	
  

–  Flows-­‐in	
  valid	
  only	
  if	
  the	
  corresponding	
  Flows-­‐out	
  occurs	
  in	
  
an	
  earlier	
  iteraMon	
  

•  On-­‐demand	
  analysis	
  using	
  cstore 	
  	
  
ontext-­‐free	
  language	
  
store 	
  	
  
store 	
  	
  
store 	
  
Order4!
Order[]23!
Customer?!
Customer[]10!
Transaction1!
reachability	
  to	
  match	
  store/load	
  and	
  call/return	
  
24

26	
  

22

?

9
StaMc	
  Analysis	
  Outline
	
  
•  Object:	
  pair	
  of	
  allocaMon	
  site	
  and	
  calling	
  context	
  
•  Flows-­‐out	
  path	
  
–  Loop	
  object	
  escaping	
  to	
  outside	
  object	
  
–  Sequence	
  of	
  store	
  statements	
  for	
  the	
  flow	
  

•  Flows-­‐in	
  path	
  

–  Escaping	
  object	
  flows	
  from	
  outside	
  object	
  into	
  the	
  loop	
  
–  Sequence	
  of	
  load	
  statements	
  causing	
  the	
  flow	
  

•  Loop	
  iteraMon	
  constraints	
  

–  Flows-­‐in	
  valid	
  only	
  if	
  the	
  corresponding	
  Flows-­‐out	
  occurs	
  in	
  
an	
  earlier	
  iteraMon	
  

•  On-­‐demand	
  analysis	
  using	
  context-­‐free	
  language	
  
reachability	
  to	
  match	
  store/load	
  and	
  call/return	
  
27	
  
StaMc	
  Analysis	
  Outline
	
  
•  Object:	
  pair	
  of	
  allocaMon	
  site	
  and	
  calling	
  context	
  
•  Flows-­‐out	
  path	
  
–  Loop	
  object	
  escaping	
  to	
  outside	
  object	
  
–  Sequence	
  of	
  store	
  statements	
  for	
  the	
  flow	
  

•  Flows-­‐in	
  path	
  

–  Escaping	
  object	
  flows	
  from	
  outside	
  object	
  into	
  the	
  loop	
  
–  Sequence	
  of	
  load	
  statements	
  causing	
  the	
  flow	
  

•  Loop	
  iteraMon	
  constraints	
  

–  Flows-­‐in	
  valid	
  only	
  if	
  the	
  corresponding	
  Flows-­‐out	
  occurs	
  in	
  
an	
  earlier	
  iteraMon	
  

•  On-­‐demand	
  analysis	
  using	
  context-­‐free	
  language	
  
Transaction1
reachability	
  to	
  match	
  s! tore/load	
  aOrderall/return	
  
nd	
  c 4,i-1!
28	
  

load11/prev	
  
StaMc	
  Analysis	
  Outline
	
  
•  Object:	
  pair	
  of	
  allocaMon	
  site	
  and	
  calling	
  context	
  
•  Flows-­‐out	
  path	
  
–  Loop	
  object	
  escaping	
  to	
  outside	
  object	
  
–  Sequence	
  of	
  store	
  statements	
  for	
  the	
  flow	
  

•  Flows-­‐in	
  path	
  

–  Escaping	
  object	
  flows	
  from	
  outside	
  object	
  into	
  the	
  loop	
  
–  Sequence	
  of	
  load	
  statements	
  causing	
  the	
  flow	
  

•  Loop	
  iteraMon	
  constraints	
  

–  Flows-­‐in	
  valid	
  only	
  if	
  the	
  corresponding	
  Flows-­‐out	
  occurs	
  in	
  
an	
  earlier	
  iteraMon	
  

•  On-­‐demand	
  analysis	
  using	
  context-­‐free	
  language	
  
reachability	
  to	
  match	
  store/load	
  and	
  call/return	
  
29	
  
StaMc	
  Analysis	
  Outline
	
  
•  Object:	
  pair	
  of	
  allocaMon	
  site	
  and	
  calling	
  context	
  
•  Flows-­‐out	
  path	
  
–  Loop	
  object	
  escaping	
  to	
  outside	
  object	
  
–  Sequence	
  of	
  store	
  statements	
  for	
  the	
  flow	
  

•  Flows-­‐in	
  path	
  

–  Escaping	
  object	
  flows	
  from	
  outside	
  object	
  into	
  the	
  loop	
  
–  Sequence	
  of	
  load	
  statements	
  causing	
  the	
  flow	
  

•  Loop	
  iteraMon	
  constraints	
  

–  Flows-­‐in	
  valid	
  only	
  if	
  the	
  corresponding	
  Flows-­‐out	
  occurs	
  in	
  
an	
  earlier	
  iteraMon	
  

•  On-­‐demand	
  analysis	
  using	
  context-­‐free	
  language	
  bject	
  
outside	
  o
reachability	
  to	
  match	
  store/load	
  and	
  Transaction1!
call/return	
  
30	
  
StaMc	
  Analysis	
  Outline
	
  
•  Object:	
  pair	
  of	
  allocaMon	
  site	
  and	
  calling	
  context	
  
•  Flows-­‐out	
  path	
  
–  Loop	
  object	
  escaping	
  to	
  outside	
  object	
  
–  Sequence	
  of	
  store	
  statements	
  for	
  the	
  flow	
  

•  Flows-­‐in	
  path	
  

–  Escaping	
  object	
  flows	
  from	
  outside	
  object	
  into	
  the	
  loop	
  
–  Sequence	
  of	
  load	
  statements	
  causing	
  the	
  flow	
  

•  Loop	
  iteraMon	
  constraints	
  

–  Flows-­‐in	
  valid	
  only	
  if	
  the	
  corresponding	
  Flows-­‐out	
  occurs	
  in	
  
an	
  earlier	
  iteraMon	
  

•  On-­‐demand	
  analysis	
  using	
  context-­‐free	
  language	
  bject	
  
outside	
  o
reachability	
  to	
  match	
  store/load	
  and	
  Transaction1!
call/return	
  
Order4,i!
31	
  

i-­‐th	
  itera,on	
  
StaMc	
  Analysis	
  Outline
	
  
•  Object:	
  pair	
  of	
  allocaMon	
  site	
  and	
  calling	
  context	
  
•  Flows-­‐out	
  path	
  
–  Loop	
  object	
  escaping	
  to	
  outside	
  object	
  
–  Sequence	
  of	
  store	
  statements	
  for	
  the	
  flow	
  

•  Flows-­‐in	
  path	
  

–  Escaping	
  object	
  flows	
  from	
  outside	
  object	
  into	
  the	
  loop	
  
–  Sequence	
  of	
  load	
  statements	
  causing	
  the	
  flow	
  

•  Loop	
  iteraMon	
  constraints	
  

–  Flows-­‐in	
  valid	
  only	
  if	
  the	
  corresponding	
  Flows-­‐out	
  occurs	
  in	
  
an	
  earlier	
  iteraMon	
  

•  On-­‐demand	
  analysis	
  using	
  context-­‐free	
  language	
  bject	
  
outside	
  o
reachability	
  to	
  match	
  store/load	
  and	
  Transaction1!
call/return	
  
Order4,i!
32	
  

i-­‐th	
  itera,on	
  

store16/prev	
  
StaMc	
  Analysis	
  Outline
	
  
•  Object:	
  pair	
  of	
  allocaMon	
  site	
  and	
  calling	
  context	
  
•  Flows-­‐out	
  path	
  
–  Loop	
  object	
  escaping	
  to	
  outside	
  object	
  
–  Sequence	
  of	
  store	
  statements	
  for	
  the	
  flow	
  

•  Flows-­‐in	
  path	
  

–  Escaping	
  object	
  flows	
  from	
  outside	
  object	
  into	
  the	
  loop	
  
–  Sequence	
  of	
  load	
  statements	
  causing	
  the	
  flow	
  

•  Loop	
  iteraMon	
  constraints	
  

–  Flows-­‐in	
  valid	
  only	
  if	
  the	
  corresponding	
  Flows-­‐out	
  occurs	
  in	
  
an	
  earlier	
  iteraMon	
  

•  On-­‐demand	
  analysis	
  using	
  context-­‐free	
  language	
  bject	
  
(i+1)-­‐th	
  itera,on	
  
load /prev	
  
outside	
  o
reachability	
  to	
  match	
  store/load	
  and	
  Transaction1!
call/return	
  
Order4,i!
11

33	
  

i-­‐th	
  itera,on	
  

store16/prev	
  
StaMc	
  Analysis	
  Outline
	
  
•  Object:	
  pair	
  of	
  allocaMon	
  site	
  and	
  calling	
  context	
  
•  Flows-­‐out	
  path	
  
–  Loop	
  object	
  escaping	
  to	
  outside	
  object	
  
–  Sequence	
  of	
  store	
  statements	
  for	
  the	
  flow	
  

•  Flows-­‐in	
  path	
  

–  Escaping	
  object	
  flows	
  from	
  outside	
  object	
  into	
  the	
  loop	
  
–  Sequence	
  of	
  load	
  statements	
  causing	
  the	
  flow	
  

•  Loop	
  iteraMon	
  constraints	
  

–  Flows-­‐in	
  valid	
  only	
  if	
  the	
  corresponding	
  Flows-­‐out	
  occurs	
  in	
  
an	
  earlier	
  iteraMon	
  
–  Captured	
  b analysis	
  u recency	
  abstracMon	
   ERA)	
  
•  On-­‐demand	
  y	
  extended	
  sing	
  context-­‐free	
  l(anguage	
  

reachability	
  to	
  match	
  store/load	
  and	
  call/return	
  

34	
  
StaMc	
  Analysis	
  Outline	
  (cont.)
	
  
•  On-­‐demand	
  analysis	
  

–  Detect	
  leaks	
  only	
  for	
  objects	
  allocated	
  in	
  specified	
  loops	
  
–  Context-­‐free	
  language	
  reachability	
  to	
  match	
  relevant	
  store/
load	
  and	
  call/return	
  

•  ConservaMve	
  handling	
  of	
  thread	
  lifeMme	
  

–  Assume	
  the	
  lifeMme	
  of	
  each	
  thread	
  exceeds	
  the	
  loop	
  lifeMme	
  
–  Capture	
  objects	
  leaking	
  to	
  long-­‐running	
  threads	
  

35	
  
Analysis	
  ImplementaMon
	
  
•  Memory	
  leak	
  

–  An	
  object	
  leaks	
  if	
  it	
  starts	
  a	
  flows-­‐out	
  path,	
  but	
  does	
  not	
  have	
  
a	
  matching	
  flows-­‐in	
  path	
  

•  ReporMng	
  leaks	
  

–  Leaking	
  object,	
  with	
  calling	
  context	
  of	
  its	
  allocaMon	
  
–  Outside	
  target	
  object,	
  with	
  calling	
  context	
  of	
  its	
  allocaMon	
  
–  Escape-­‐causing	
  heap	
  write	
  (store)	
  statement,	
  with	
  its	
  calling	
  
context	
  

•  LeakChecker:	
  leak	
  detecMon	
  tool	
  built	
  using	
  Soot	
  
	
  
36	
  
EvaluaMon
	
  
•  8	
  real-­‐world	
  Java	
  programs	
  

–  Enterprise	
  trading,	
  so5ware	
  tools,	
  databases,	
  logging	
  
–  3	
  programs	
  never	
  studied	
  by	
  exisMng	
  work	
  

•  EffecMve	
  for	
  leak	
  detecMon?	
  

–  LeakChecker	
  detected	
  both	
  known	
  and	
  new	
  leaks	
  

•  Suitable	
  for	
  pracMcal	
  use?	
  

–  Analysis	
  running	
  Mme	
  (all	
  <	
  35	
  mins)	
  
–  Reasonable	
  false	
  posiMve	
  rate	
  (avg	
  <	
  50%)	
  

•  Case	
  studies	
  

37	
  

–  Performed	
  to	
  understand	
  quality	
  of	
  leak	
  report	
  
–  For	
  each	
  leak	
  defect,	
  pinpoint	
  root	
  cause	
  and	
  fix	
  the	
  problem	
  
in	
  <	
  2	
  hours	
  
Eclipse	
  Diff
	
  
•  Scenario:	
  compare	
  two	
  large	
  JAR	
  files	
  

–  runCompare	
  method	
  in	
  compare	
  plugin!
–  An	
  arMficial	
  loop	
  to	
  invoke	
  runCompare	
  mulMple	
  Mmes	
  

•  Loop	
  objects	
  

–  Editor:	
  display	
  comparison	
  results	
  
–  HistoryEntry:	
  represent	
  list	
  of	
  opened	
  editors,	
  and	
  allow	
  

users	
  to	
  navigate	
  them	
  backward/forward	
  

•  Outside	
  object	
  

–  History:	
  managed	
  by	
  another	
  plugin	
  to	
  save	
  HistoryEntry	
  

	
  
38	
  

compare	
  plugin	
  

!!!!

Editor!
loop	
  objects	
  

history	
  plugin	
  

HistoryEntry!

History!
outside	
  object	
  
Conclusions
	
  
•  LeakChecker	
  is	
  both	
  effecMve	
  and	
  pracMcal	
  
•  Key	
  insights	
  

–  Capture	
  common	
  paVerns	
  of	
  leaking	
  behavior	
  
–  Focus	
  on	
  user-­‐specified	
  event	
  loops	
  
–  Report	
  leaks	
  with	
  detailed	
  context	
  informaMon	
  

	
  

39	
  
Thank	
  	
  you
	
  
40	
  

More Related Content

Viewers also liked

Search Intelligence - Social Media e Search Marketing - Proxxima 2011
Search Intelligence - Social Media e Search Marketing - Proxxima 2011Search Intelligence - Social Media e Search Marketing - Proxxima 2011
Search Intelligence - Social Media e Search Marketing - Proxxima 2011Leonardo Naressi
 
Cultura de Métricas para SEO (UaiSEO)
Cultura de Métricas para SEO (UaiSEO)Cultura de Métricas para SEO (UaiSEO)
Cultura de Métricas para SEO (UaiSEO)Leonardo Naressi
 
Isha Arogya Information
Isha Arogya InformationIsha Arogya Information
Isha Arogya InformationIsha Outreach
 
Pixel Toy
Pixel ToyPixel Toy
Pixel ToyMariana
 
Liberalismo 3.0: o terceiro ciclo de descentralização da humanidade
Liberalismo 3.0:  o terceiro ciclo de descentralização da humanidadeLiberalismo 3.0:  o terceiro ciclo de descentralização da humanidade
Liberalismo 3.0: o terceiro ciclo de descentralização da humanidadeCarlos Nepomuceno (Nepô)
 
La vida entre capazos
La vida entre capazosLa vida entre capazos
La vida entre capazoslugifel
 
Myers Dill and Sam Digirolamo Presentation
Myers Dill and Sam Digirolamo PresentationMyers Dill and Sam Digirolamo Presentation
Myers Dill and Sam Digirolamo PresentationBronwen Elizabeth Madden
 
Chapter5
Chapter5Chapter5
Chapter5alipuko
 
5 ways to increase sales effectiveness
5 ways to increase sales effectiveness5 ways to increase sales effectiveness
5 ways to increase sales effectivenessJeff Cortez
 
Passeioda8seriefazzendaparkhotel
Passeioda8seriefazzendaparkhotelPasseioda8seriefazzendaparkhotel
Passeioda8seriefazzendaparkhotelmidiasvidal
 
Telefórmula 18octubre2016
Telefórmula   18octubre2016Telefórmula   18octubre2016
Telefórmula 18octubre2016srtrendingtopic
 

Viewers also liked (20)

Curso formação gerencial - apresentação
Curso   formação gerencial - apresentaçãoCurso   formação gerencial - apresentação
Curso formação gerencial - apresentação
 
Search Intelligence - Social Media e Search Marketing - Proxxima 2011
Search Intelligence - Social Media e Search Marketing - Proxxima 2011Search Intelligence - Social Media e Search Marketing - Proxxima 2011
Search Intelligence - Social Media e Search Marketing - Proxxima 2011
 
Cultura de Métricas para SEO (UaiSEO)
Cultura de Métricas para SEO (UaiSEO)Cultura de Métricas para SEO (UaiSEO)
Cultura de Métricas para SEO (UaiSEO)
 
Isha Arogya Information
Isha Arogya InformationIsha Arogya Information
Isha Arogya Information
 
Pixel Toy
Pixel ToyPixel Toy
Pixel Toy
 
Libres en cristo 3
Libres en cristo 3Libres en cristo 3
Libres en cristo 3
 
Bruxa
BruxaBruxa
Bruxa
 
Liberalismo 3.0: o terceiro ciclo de descentralização da humanidade
Liberalismo 3.0:  o terceiro ciclo de descentralização da humanidadeLiberalismo 3.0:  o terceiro ciclo de descentralização da humanidade
Liberalismo 3.0: o terceiro ciclo de descentralização da humanidade
 
Presentación de la Consultoría Industrial X efficiency
Presentación de la Consultoría Industrial X efficiency Presentación de la Consultoría Industrial X efficiency
Presentación de la Consultoría Industrial X efficiency
 
La vida entre capazos
La vida entre capazosLa vida entre capazos
La vida entre capazos
 
des achats
des achatsdes achats
des achats
 
Liga 9 y 10 noviembre
Liga 9 y 10 noviembreLiga 9 y 10 noviembre
Liga 9 y 10 noviembre
 
Опыт XML
Опыт XMLОпыт XML
Опыт XML
 
Myers Dill and Sam Digirolamo Presentation
Myers Dill and Sam Digirolamo PresentationMyers Dill and Sam Digirolamo Presentation
Myers Dill and Sam Digirolamo Presentation
 
Chapter5
Chapter5Chapter5
Chapter5
 
5 ways to increase sales effectiveness
5 ways to increase sales effectiveness5 ways to increase sales effectiveness
5 ways to increase sales effectiveness
 
Você tem...
Você tem...Você tem...
Você tem...
 
Passeioda8seriefazzendaparkhotel
Passeioda8seriefazzendaparkhotelPasseioda8seriefazzendaparkhotel
Passeioda8seriefazzendaparkhotel
 
Machine response
Machine responseMachine response
Machine response
 
Telefórmula 18octubre2016
Telefórmula   18octubre2016Telefórmula   18octubre2016
Telefórmula 18octubre2016
 

Similar to LeakChecker: Practical Static Memory Leak Detection for Managed Languages

F# as our day job by 2016
F# as our day job by 2016F# as our day job by 2016
F# as our day job by 2016Tomas Jansson
 
Effective C#
Effective C#Effective C#
Effective C#lantoli
 
C++ program: All tasks .cpp
C++ program: All tasks .cppC++ program: All tasks .cpp
C++ program: All tasks .cppKhalid Waleed
 
CDC Stream Processing With Apache Flink With Timo Walther | Current 2022
CDC Stream Processing With Apache Flink With Timo Walther | Current 2022CDC Stream Processing With Apache Flink With Timo Walther | Current 2022
CDC Stream Processing With Apache Flink With Timo Walther | Current 2022HostedbyConfluent
 
Changelog Stream Processing with Apache Flink
Changelog Stream Processing with Apache FlinkChangelog Stream Processing with Apache Flink
Changelog Stream Processing with Apache FlinkFlink Forward
 

Similar to LeakChecker: Practical Static Memory Leak Detection for Managed Languages (9)

F# as our day job by 2016
F# as our day job by 2016F# as our day job by 2016
F# as our day job by 2016
 
Effective C#
Effective C#Effective C#
Effective C#
 
Introduction to typescript
Introduction to typescriptIntroduction to typescript
Introduction to typescript
 
Functional DDD
Functional DDDFunctional DDD
Functional DDD
 
Useful c programs
Useful c programsUseful c programs
Useful c programs
 
C++ program: All tasks .cpp
C++ program: All tasks .cppC++ program: All tasks .cpp
C++ program: All tasks .cpp
 
CDC Stream Processing With Apache Flink With Timo Walther | Current 2022
CDC Stream Processing With Apache Flink With Timo Walther | Current 2022CDC Stream Processing With Apache Flink With Timo Walther | Current 2022
CDC Stream Processing With Apache Flink With Timo Walther | Current 2022
 
Day 1
Day 1Day 1
Day 1
 
Changelog Stream Processing with Apache Flink
Changelog Stream Processing with Apache FlinkChangelog Stream Processing with Apache Flink
Changelog Stream Processing with Apache Flink
 

More from Dacong (Tony) Yan

Static Reference Analysis for GUI Objects in Android Software
Static Reference Analysis for GUI Objects in Android SoftwareStatic Reference Analysis for GUI Objects in Android Software
Static Reference Analysis for GUI Objects in Android SoftwareDacong (Tony) Yan
 
Systematic Testing for Resource Leaks in Android Applications
Systematic Testing for Resource Leaks in Android ApplicationsSystematic Testing for Resource Leaks in Android Applications
Systematic Testing for Resource Leaks in Android ApplicationsDacong (Tony) Yan
 
SherLog: Error Diagnosis by Connecting Clues from Run-time Logs
SherLog: Error Diagnosis by Connecting Clues from Run-time LogsSherLog: Error Diagnosis by Connecting Clues from Run-time Logs
SherLog: Error Diagnosis by Connecting Clues from Run-time LogsDacong (Tony) Yan
 
Efficient Diversity-Aware Search
Efficient Diversity-Aware SearchEfficient Diversity-Aware Search
Efficient Diversity-Aware SearchDacong (Tony) Yan
 
Demand-Driven Context-Sensitive Alias Analysis for Java
Demand-Driven Context-Sensitive Alias Analysis for JavaDemand-Driven Context-Sensitive Alias Analysis for Java
Demand-Driven Context-Sensitive Alias Analysis for JavaDacong (Tony) Yan
 
Rethinking Soot for Summary-Based Whole-Program Analysis
Rethinking Soot for Summary-Based Whole-Program AnalysisRethinking Soot for Summary-Based Whole-Program Analysis
Rethinking Soot for Summary-Based Whole-Program AnalysisDacong (Tony) Yan
 
Uncovering Performance Problems in Java Applications with Reference Propagati...
Uncovering Performance Problems in Java Applications with Reference Propagati...Uncovering Performance Problems in Java Applications with Reference Propagati...
Uncovering Performance Problems in Java Applications with Reference Propagati...Dacong (Tony) Yan
 
A Toy Virtual Machine Project
A Toy Virtual Machine ProjectA Toy Virtual Machine Project
A Toy Virtual Machine ProjectDacong (Tony) Yan
 

More from Dacong (Tony) Yan (10)

Static Reference Analysis for GUI Objects in Android Software
Static Reference Analysis for GUI Objects in Android SoftwareStatic Reference Analysis for GUI Objects in Android Software
Static Reference Analysis for GUI Objects in Android Software
 
Systematic Testing for Resource Leaks in Android Applications
Systematic Testing for Resource Leaks in Android ApplicationsSystematic Testing for Resource Leaks in Android Applications
Systematic Testing for Resource Leaks in Android Applications
 
SherLog: Error Diagnosis by Connecting Clues from Run-time Logs
SherLog: Error Diagnosis by Connecting Clues from Run-time LogsSherLog: Error Diagnosis by Connecting Clues from Run-time Logs
SherLog: Error Diagnosis by Connecting Clues from Run-time Logs
 
Efficient Diversity-Aware Search
Efficient Diversity-Aware SearchEfficient Diversity-Aware Search
Efficient Diversity-Aware Search
 
AVIO class present
AVIO class presentAVIO class present
AVIO class present
 
Demand-Driven Context-Sensitive Alias Analysis for Java
Demand-Driven Context-Sensitive Alias Analysis for JavaDemand-Driven Context-Sensitive Alias Analysis for Java
Demand-Driven Context-Sensitive Alias Analysis for Java
 
Rethinking Soot for Summary-Based Whole-Program Analysis
Rethinking Soot for Summary-Based Whole-Program AnalysisRethinking Soot for Summary-Based Whole-Program Analysis
Rethinking Soot for Summary-Based Whole-Program Analysis
 
Uncovering Performance Problems in Java Applications with Reference Propagati...
Uncovering Performance Problems in Java Applications with Reference Propagati...Uncovering Performance Problems in Java Applications with Reference Propagati...
Uncovering Performance Problems in Java Applications with Reference Propagati...
 
A Toy Virtual Machine Project
A Toy Virtual Machine ProjectA Toy Virtual Machine Project
A Toy Virtual Machine Project
 
Scope vs YSmart
Scope vs YSmartScope vs YSmart
Scope vs YSmart
 

Recently uploaded

SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 

Recently uploaded (20)

SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 

LeakChecker: Practical Static Memory Leak Detection for Managed Languages

  • 1. LeakChecker:  Prac,cal  Sta,c  Memory  Leak   Detec,on  for  Managed  Languages   Dacong  (Tony)  Yan1,  Guoqing  Xu2,  Shengqian  Yang1,  Atanas  Rountev1     1  Ohio  State  University   2  University  of  California,  Irvine     PRESTO:  Program  Analyses  and  So5ware  Tools  Research  Group,  Ohio  State  University  
  • 2. Memory  Leaks  in  Managed  Languages   •  Languages  such  as  Java  sMll  have  memory  leaks:   unnecessary  references  keep  unused  objects  alive   •  StaMc  leak  detecMon   –  Widely  used  for  unmanaged  languages  such  as  C   –  Cannot  be  applied  to  managed  languages:  no  explicit  memory   deallocaMon   •  General  definiMon  of  leaks   –  Precision:  difficult  to  compute  object  liveness  precisely   –  Performance:  limited  scalability  for  large  programs   •  Our  approach   –  Shi5  the  focus,  and  idenMfy  common  leak  paVerns   2  
  • 3. Proposed  Leak  DetecMon  for  Java   •  ObservaMon:  leaks  are  o5en  related  to  frequently   occurring  events  (e.g.,  loop  iteraMons)   •  SoluMon:  focus  on  a  user-­‐specified  event  loop   •  ObservaMon:  a  leaking  object  is  o5en   –  created  by  one  loop  iteraMon   –  escapes  this  iteraMon   –  never  used  in  later  iteraMons   •  SoluMon:  interprocedural  tracking  of   3   –  whether  an  object  escapes  to  a  memory  locaMon  outside  of   the  loop   –  whether  an  escaping  object  flows  from  the  outside  locaMon   back  into  a  later  loop  iteraMon  
  • 4. Example   “main”:! 7 class Transaction {! 1 Transaction t = new Transaction();! 8 Order prev;! 2 for (int i = 0; i < X; ++i) {! Customer[] custs = new Customer[…]; 9 3 t.display();! 10 4 Order order = new Order(...);! 11 Order r = this.prev;! 5 t.process(order);! 12 … // display r! 13 this.prev = null; // remove! 6 }! void display() {! ! 14 } ! 21 class Customer {! 15 void process(Order p) {! 22 Order[] orders = new Order[…];! 16 this.prev = p;! 23 void addOrder(Order q) {! 17 Customer c = this.custs[…];! 18 c.addOrder(p);! 19 ... // process p! 24 25 this.orders[...] = q;! }! 26 }! 20 ! } }! An  example  adapted  from  SPECjbb2000   ! 4  
  • 5. Example   “main”:! 7 class Transaction {! 1 Transaction t = new Transaction();! 8 Order prev;! 2 for (int i = 0; i < X; ++i) {! Customer[] custs = new Customer[…]; 9 3 t.display();! 10 4 Order order = new Order(...);! 11 Order r = this.prev;! 5 t.process(order);! 12 … // display r! 13 this.prev = null; // remove! 6 }! void display() {! ! 14 } ! 21 class Customer {! 15 void process(Order p) {! 22 Order[] orders = new Order[…];! 16 this.prev = p;! 23 void addOrder(Order q) {! 17 Customer c = this.custs[…];! 18 c.addOrder(p);! 19 ... // process p! 24 25 this.orders[...] = q;! }! 26 }! 20 ! } }! An  example  adapted  from  SPECjbb2000   ! 5  
  • 6. Example   “main”:! 7 class Transaction {! 1 Transaction t = new Transaction();! 8 Order prev;! 2 for (int i = 0; i < X; ++i) {! Customer[] custs = new Customer[…]; 9 3 t.display();! 10 4 Order order = new Order(...);! 11 Order r = this.prev;! 5 t.process(order);! 12 … // display r! 13 this.prev = null; // remove! 6 }! loop  object   ! void display() {! 14 } ! 21 class Customer {! 15 void process(Order p) {! 22 Order[] orders = new Order[…];! 16 this.prev = p;! 23 void addOrder(Order q) {! 17 Customer c = this.custs[…];! 18 c.addOrder(p);! 19 ... // process p! 24 25 this.orders[...] = q;! }! 26 }! ! 20 ! 6   } }!
  • 7. “main”:! outside  object   Example   7 class Transaction {! 1 Transaction t = new Transaction();! 8 Order prev;! 2 for (int i = 0; i < X; ++i) {! Customer[] custs = new Customer[…]; 9 3 t.display();! 10 4 Order order = new Order(...);! 11 Order r = this.prev;! 5 t.process(order);! 12 … // display r! 13 this.prev = null; // remove! 6 }! loop  object   ! void display() {! 14 } ! 21 class Customer {! 15 void process(Order p) {! 22 Order[] orders = new Order[…];! 16 this.prev = p;! 23 void addOrder(Order q) {! 17 Customer c = this.custs[…];! 18 c.addOrder(p);! 19 ... // process p! 24 25 this.orders[...] = q;! }! 26 }! ! 20 ! 7   } }!
  • 8. “main”:! outside  object   Example   7 class Transaction {! 1 Transaction t = new Transaction();! 8 Order prev;! 2 for (int i = 0; i < X; ++i) {! Customer[] custs = new Customer[…]; 9 3 t.display();! 10 4 Order order = new Order(...);! 11 Order r = this.prev;! 5 t.process(order);! 12 … // display r! 13 this.prev = null; // remove! 6 }! loop  object   ! void display() {! 14 } ! 21 class Customer {! 15 void process(Order p) {! 22 Order[] orders = new Order[…];! 16 this.prev = p;! 23 void addOrder(Order q) {! 17 Customer c = this.custs[…];! 18 c.addOrder(p);! 19 ... // process p! 24 25 this.orders[...] = q;! }! 26 }! ! 20 ! 8   } }!
  • 9. “main”:! outside  object   Example   7 class Transaction {! 1 Transaction t = new Transaction();! 8 Order prev;! 2 for (int i = 0; i < X; ++i) {! Customer[] custs = new Customer[…]; 9 3 t.display();! 10 4 Order order = new Order(...);! 11 Order r = this.prev;! 5 t.process(order);! 12 … // display r! 13 this.prev = null; // remove! 6 }! loop  object   ! void display() {! 14 } ! 21 class Customer {! 15 void process(Order p) {! 22 Order[] orders = new Order[…];! 16 this.prev = p;! 23 void addOrder(Order q) {! 17 Customer c = this.custs[…];! 18 c.addOrder(p);! 19 ... // process p! 24 25 this.orders[...] = q;! }! 26 }! ! 20 ! 9   } }!
  • 10. Example   “main”:! 7 class Transaction {! 1 Transaction t = new Transaction();! 8 Order prev;! 2 for (int i = 0; i < X; ++i) {! Customer[] custs = new Customer[…]; 9 3 t.display();! 10 4 Order order = new Order(...);! 11 Order r = this.prev;! 5 t.process(order);! 12 … // display r! 13 this.prev = null; // remove! 6 }! void display() {! ! 14 } ! 21 class Customer {! 15 void process(Order p) {! 22 Order[] orders = new Order[…];! 16 this.prev = p;! 23 void addOrder(Order q) {! 17 Customer c = this.custs[…];! 18 c.addOrder(p);! 19 ... // process p! 24 25 this.orders[...] = q;! }! 26 }! ! 20 ! 10   } }!
  • 11. Example   “main”:! 7 class Transaction {! 1 Transaction t = new Transaction();! 8 Order prev;! 2 for (int i = 0; i < X; ++i) {! Customer[] custs = new Customer[…]; 9 3 t.display();! 10 4 Order order = new Order(...);! 11 Order r = this.prev;! 5 t.process(order);! 12 … // display r! 13 this.prev = null; // remove! 6 }! void display() {! ! 14 } ! 21 class Customer {! 15 void process(Order p) {! 22 Order[] orders = new Order[…];! 16 this.prev = p;! 23 void addOrder(Order q) {! 17 Customer c = this.custs[…];! 18 c.addOrder(p);! 19 ... // process p! 24 25 this.orders[...] = q;! }! 26 }! ! 20 ! 11   } }!
  • 12. Example   “main”:! 7 class Transaction {! 1 Transaction t = new Transaction();! 8 Order prev;! 2 for (int i = 0; i < X; ++i) {! Customer[] custs = new Customer[…]; 9 3 t.display();! 10 4 Order order = new Order(...);! 11 Order r = this.prev;! 5 t.process(order);! 12 … // display r! 13 this.prev = null; // remove! 6 }! void display() {! ! 14 } ! 21 class Customer {! 15 void process(Order p) {! 22 Order[] orders = new Order[…];! 16 23 void addOrder(Order q) {! 17 this.prev = p;! store16   Customer c = this.custs[…];! 18 c.addOrder(p);! 19 ... // process p! 24 25 this.orders[...] = q;! }! 26 }! ! 20 ! 12   } }!
  • 13. Example   “main”:! 7 class Transaction {! 1 Transaction t = new Transaction();! 8 Order prev;! 2 for (int i = 0; i < X; ++i) {! Customer[] custs = new Customer[…]; 9 3 t.display();! 10 4 Order order = new Order(...);! 11 Order r = this.prev;! 5 t.process(order);! 12 … // display r! 13 this.prev = null; // remove! 6 }! void display() {! ! 14 } ! 21 class Customer {! 15 void process(Order p) {! 22 Order[] orders = new Order[…];! 16 23 void addOrder(Order q) {! 17 this.prev = p;! store16   Customer c = this.custs[…];! 18 c.addOrder(p);! 19 ... // process p! 24 25 this.orders[...] = q;! }! 26 }! Order4! store16   20 Transaction1! ! ! 13   escape   } }!
  • 14. Example   “main”:! 7 class Transaction {! 1 Transaction t = new Transaction();! 8 Order prev;! 2 for (int i = 0; i < X; ++i) {! Customer[] custs = new Customer[…]; 9 3 t.display();! 10 4 Order order = new Order(...);! 11 Order r = this.prev;! 5 t.process(order);! 12 … // display r! 13 this.prev = null; // remove! 6 }! void display() {! ! 14 } ! 21 class Customer {! 15 void process(Order p) {! 22 Order[] orders = new Order[…];! 16 this.prev = p;! 23 void addOrder(Order q) {! 17 Customer c = this.custs[…];! 18 c.addOrder(p);! 19 ... // process p! this.orders[...] = q;! store24   24 25 }! 26 }! ! 20 ! 14   } }!
  • 15. Example   “main”:! 7 class Transaction {! 1 Transaction t = new Transaction();! 8 Order prev;! 2 for (int i = 0; i < X; ++i) {! Customer[] custs = new Customer[…]; 9 3 t.display();! 10 4 Order order = new Order(...);! 11 Order r = this.prev;! 5 t.process(order);! 12 … // display r! 13 this.prev = null; // remove! 6 }! void display() {! ! 14 } ! 21 class Customer {! 15 void process(Order p) {! 22 Order[] orders = new Order[…];! 16 this.prev = p;! 23 void addOrder(Order q) {! 17 Customer c = this.custs[…];! 18 c.addOrder(p);! 19 ... // process p! this.orders[...] = q;! store24   24 25 }! 26 }! Order4! 15   20 store24     Order[]23! store22     ! Customer?! ! } store?     escape   }! Customer[]10! store9   Transaction1!
  • 16. Example   “main”:! 7 class Transaction {! 1 Transaction t = new Transaction();! 8 Order prev;! 2 for (int i = 0; i < X; ++i) {! Customer[] custs = new Customer[…]; 9 3 t.display();! 10 4 Order order = new Order(...);! 11 Order r = this.prev;! 5 t.process(order);! 12 … // display r! 13 this.prev = null; // remove! 6 }! void display() {! ! 14 } ! 21 class Customer {! 15 void process(Order p) {! 22 Order[] orders = new Order[…];! 16 this.prev = p;! 23 void addOrder(Order q) {! 17 Customer c = this.custs[…];! 18 c.addOrder(p);! 19 ... // process p! 24 25 this.orders[...] = q;! }! 26 }! ! Order4,i! 16   20 store24/orders,  …,  store9/custs     store16/prev   } }! Transaction1! !
  • 17. Example   “main”:! 7 class Transaction {! 1 Transaction t = new Transaction();! 8 Order prev;! 2 for (int i = 0; i < X; ++i) {! Customer[] custs = new Customer[…]; 9 3 t.display();! 10 4 Order order = new Order(...);! 11 Order r = this.prev;! 5 t.process(order);! 12 … // display r! 13 this.prev = null; // remove! 6 }! void display() {! ! 14 } ! 21 class Customer {! 15 void process(Order p) {! 22 Order[] orders = new Order[…];! 16 this.prev = p;! 23 void addOrder(Order q) {! 17 Customer c = this.custs[…];! 18 c.addOrder(p);! 19 ... // process p! 24 25 this.orders[...] = q;! }! 26 }! Order4,i! 17   store24/orders,  …,  store9/custs     20 leaking?   ! } }! Transaction1! !
  • 18. Example   “main”:! 7 class Transaction {! 1 Transaction t = new Transaction();! 8 Order prev;! 2 for (int i = 0; i < X; ++i) {! Customer[] custs = new Customer[…]; 9 3 t.display();! 10 4 Order order = new Order(...);! 11 Order r = this.prev;! 5 t.process(order);! 12 … // display r! 13 this.prev = null; // remove! 6 }! void display() {! ! 14 } ! 21 class Customer {! 15 void process(Order p) {! 22 Order[] orders = new Order[…];! 16 this.prev = p;! 23 void addOrder(Order q) {! 17 Customer c = this.custs[…];! 18 c.addOrder(p);! 19 ... // process p! 24 25 this.orders[...] = q;! }! 26 }! 20 ! Order4,i! 18   store16/prev   } }! Transaction1! ! leaking?  
  • 19. Example   “main”:! 7 class Transaction {! 1 Transaction t = new Transaction();! 8 Order prev;! 2 for (int i = 0; i < X; ++i) {! Customer[] custs = new Customer[…]; 9 3 t.display();! 10 4 Order order = new Order(...);! 11 Order r = this.prev;! 5 t.process(order);! 12 … // display r! 13 this.prev = null; // remove! 6 }! void display() {! load11   ! 14 } ! 21 class Customer {! 15 void process(Order p) {! 22 Order[] orders = new Order[…];! 16 this.prev = p;! 23 void addOrder(Order q) {! 17 Customer c = this.custs[…];! 18 c.addOrder(p);! 19 ... // process p! 24 25 this.orders[...] = q;! }! 26 }! 20 ! Order4,i! 19   store16/prev   } }! Transaction1! ! leaking?  
  • 20. Example   “main”:! 7 class Transaction {! 1 Transaction t = new Transaction();! 8 Order prev;! 2 for (int i = 0; i < X; ++i) {! Customer[] custs = new Customer[…]; 9 3 t.display();! 10 4 Order order = new Order(...);! 11 Order r = this.prev;! 5 t.process(order);! 12 … // display r! 13 this.prev = null; // remove! 6 }! void display() {! load11   ! 14 } ! 21 class Customer {! 15 void process(Order p) {! 22 Order[] orders = new Order[…];! 16 this.prev = p;! 23 void addOrder(Order q) {! 17 Customer c = this.custs[…];! 18 c.addOrder(p);! 19 ... // process p! 24 25 this.orders[...] = q;! }! 26 }! 20 ! Order4,i! 20   store16/prev   } }! Transaction1! ! leaking?   store16  
  • 21. Example   “main”:! 7 class Transaction {! 1 Transaction t = new Transaction();! 8 Order prev;! 2 for (int i = 0; i < X; ++i) {! Customer[] custs = new Customer[…]; 9 3 t.display();! 10 4 Order order = new Order(...);! 11 Order r = this.prev;! 5 t.process(order);! 12 … // display r! 13 this.prev = null; // remove! 6 }! void display() {! load11   ! 14 } ! 21 class Customer {! 15 void process(Order p) {! 22 Order[] orders = new Order[…];! 16 this.prev = p;! 23 void addOrder(Order q) {! 17 Customer c = this.custs[…];! 18 c.addOrder(p);! 19 ... // process p! 24 25 this.orders[...] = q;! }! 26 }! load11/prev   ! Order4,i! 21   20 store16/prev   } }! Transaction1! ! leaking?   store16  
  • 22. Example   “main”:! 7 class Transaction {! 1 Transaction t = new Transaction();! 8 Order prev;! 2 for (int i = 0; i < X; ++i) {! Customer[] custs = new Customer[…]; 9 3 t.display();! 10 4 Order order = new Order(...);! 11 Order r = this.prev;! 5 t.process(order);! 12 … // display r! 13 this.prev = null; // remove! 6 }! void display() {! load11   ! 14 } ! 21 class Customer {! 15 void process(Order p) {! 22 Order[] orders = new Order[…];! 16 this.prev = p;! 23 void addOrder(Order q) {! 17 Customer c = this.custs[…];! 18 c.addOrder(p);! 19 ... // process p! 24 25 26 }! this.orders[...] = q;! }! (i+1)-­‐th  itera,on   load11/prev   ! Order4,i! 22   i-­‐th  itera,on   20 store16/prev   } }! Transaction1! ! leaking?   store16  
  • 23. Example   “main”:! 7 class Transaction {! 1 Transaction t = new Transaction();! 8 Order prev;! 2 for (int i = 0; i < X; ++i) {! Customer[] custs = new Customer[…]; 9 3 t.display();! 10 4 Order order = new Order(...);! 11 Order r = this.prev;! 5 t.process(order);! 12 … // display r! 13 this.prev = null; // remove! 6 }! void display() {! ! 14 } ! 21 class Customer {! 15 void process(Order p) {! 22 Order[] orders = new Order[…];! 16 this.prev = p;! 23 void addOrder(Order q) {! 17 Customer c = this.custs[…];! 18 c.addOrder(p);! 19 ... // process p! 24 25 this.orders[...] = q;! }! 26 }! store24/orders,  …,  store9/custs     Order4,i! 23   store16/prev   20 leaking   ! } }! Transaction1! ! non-­‐leaking  
  • 24. StaMc  Analysis  Outline   •  Object:  pair  of  allocaMon  site  and  calling  context   •  Flows-­‐out  path   –  Loop  object  escaping  to  outside  object   –  Sequence  of  store  statements  for  the  flow   •  Flows-­‐in  path   –  Escaping  object  flows  from  outside  object  into  the  loop   –  Sequence  of  load  statements  causing  the  flow   •  Loop  iteraMon  constraints   –  Flows-­‐in  valid  only  if  the  corresponding  Flows-­‐out  occurs  in   an  earlier  iteraMon   •  On-­‐demand  analysis  using  context-­‐free  language   reachability  to  match  store/load  and  call/return   24  
  • 25. StaMc  Analysis  Outline   •  Object:  pair  of  allocaMon  site  and  calling  context   •  Flows-­‐out  path   –  Loop  object  escaping  to  outside  object   –  Sequence  of  store  statements  for  the  flow   •  Flows-­‐in  path   –  Escaping  object  flows  from  outside  object  into  the  loop   –  Sequence  of  load  statements  causing  the  flow   •  Loop  iteraMon  constraints   –  Flows-­‐in  valid  only  if  the  corresponding  Flows-­‐out  occurs  in   an  earlier  iteraMon   •  On-­‐demand  analysis  using  context-­‐free  language   reachability  to  match  store/load  and  call/return   25  
  • 26. StaMc  Analysis  Outline   •  Object:  pair  of  allocaMon  site  and  calling  context   •  Flows-­‐out  path   –  Loop  object  escaping  to  outside  object   –  Sequence  of  store  statements  for  the  flow   •  Flows-­‐in  path   –  Escaping  object  flows  from  outside  object  into  the  loop   –  Sequence  of  load  statements  causing  the  flow   •  Loop  iteraMon  constraints   –  Flows-­‐in  valid  only  if  the  corresponding  Flows-­‐out  occurs  in   an  earlier  iteraMon   •  On-­‐demand  analysis  using  cstore     ontext-­‐free  language   store     store     store   Order4! Order[]23! Customer?! Customer[]10! Transaction1! reachability  to  match  store/load  and  call/return   24 26   22 ? 9
  • 27. StaMc  Analysis  Outline   •  Object:  pair  of  allocaMon  site  and  calling  context   •  Flows-­‐out  path   –  Loop  object  escaping  to  outside  object   –  Sequence  of  store  statements  for  the  flow   •  Flows-­‐in  path   –  Escaping  object  flows  from  outside  object  into  the  loop   –  Sequence  of  load  statements  causing  the  flow   •  Loop  iteraMon  constraints   –  Flows-­‐in  valid  only  if  the  corresponding  Flows-­‐out  occurs  in   an  earlier  iteraMon   •  On-­‐demand  analysis  using  context-­‐free  language   reachability  to  match  store/load  and  call/return   27  
  • 28. StaMc  Analysis  Outline   •  Object:  pair  of  allocaMon  site  and  calling  context   •  Flows-­‐out  path   –  Loop  object  escaping  to  outside  object   –  Sequence  of  store  statements  for  the  flow   •  Flows-­‐in  path   –  Escaping  object  flows  from  outside  object  into  the  loop   –  Sequence  of  load  statements  causing  the  flow   •  Loop  iteraMon  constraints   –  Flows-­‐in  valid  only  if  the  corresponding  Flows-­‐out  occurs  in   an  earlier  iteraMon   •  On-­‐demand  analysis  using  context-­‐free  language   Transaction1 reachability  to  match  s! tore/load  aOrderall/return   nd  c 4,i-1! 28   load11/prev  
  • 29. StaMc  Analysis  Outline   •  Object:  pair  of  allocaMon  site  and  calling  context   •  Flows-­‐out  path   –  Loop  object  escaping  to  outside  object   –  Sequence  of  store  statements  for  the  flow   •  Flows-­‐in  path   –  Escaping  object  flows  from  outside  object  into  the  loop   –  Sequence  of  load  statements  causing  the  flow   •  Loop  iteraMon  constraints   –  Flows-­‐in  valid  only  if  the  corresponding  Flows-­‐out  occurs  in   an  earlier  iteraMon   •  On-­‐demand  analysis  using  context-­‐free  language   reachability  to  match  store/load  and  call/return   29  
  • 30. StaMc  Analysis  Outline   •  Object:  pair  of  allocaMon  site  and  calling  context   •  Flows-­‐out  path   –  Loop  object  escaping  to  outside  object   –  Sequence  of  store  statements  for  the  flow   •  Flows-­‐in  path   –  Escaping  object  flows  from  outside  object  into  the  loop   –  Sequence  of  load  statements  causing  the  flow   •  Loop  iteraMon  constraints   –  Flows-­‐in  valid  only  if  the  corresponding  Flows-­‐out  occurs  in   an  earlier  iteraMon   •  On-­‐demand  analysis  using  context-­‐free  language  bject   outside  o reachability  to  match  store/load  and  Transaction1! call/return   30  
  • 31. StaMc  Analysis  Outline   •  Object:  pair  of  allocaMon  site  and  calling  context   •  Flows-­‐out  path   –  Loop  object  escaping  to  outside  object   –  Sequence  of  store  statements  for  the  flow   •  Flows-­‐in  path   –  Escaping  object  flows  from  outside  object  into  the  loop   –  Sequence  of  load  statements  causing  the  flow   •  Loop  iteraMon  constraints   –  Flows-­‐in  valid  only  if  the  corresponding  Flows-­‐out  occurs  in   an  earlier  iteraMon   •  On-­‐demand  analysis  using  context-­‐free  language  bject   outside  o reachability  to  match  store/load  and  Transaction1! call/return   Order4,i! 31   i-­‐th  itera,on  
  • 32. StaMc  Analysis  Outline   •  Object:  pair  of  allocaMon  site  and  calling  context   •  Flows-­‐out  path   –  Loop  object  escaping  to  outside  object   –  Sequence  of  store  statements  for  the  flow   •  Flows-­‐in  path   –  Escaping  object  flows  from  outside  object  into  the  loop   –  Sequence  of  load  statements  causing  the  flow   •  Loop  iteraMon  constraints   –  Flows-­‐in  valid  only  if  the  corresponding  Flows-­‐out  occurs  in   an  earlier  iteraMon   •  On-­‐demand  analysis  using  context-­‐free  language  bject   outside  o reachability  to  match  store/load  and  Transaction1! call/return   Order4,i! 32   i-­‐th  itera,on   store16/prev  
  • 33. StaMc  Analysis  Outline   •  Object:  pair  of  allocaMon  site  and  calling  context   •  Flows-­‐out  path   –  Loop  object  escaping  to  outside  object   –  Sequence  of  store  statements  for  the  flow   •  Flows-­‐in  path   –  Escaping  object  flows  from  outside  object  into  the  loop   –  Sequence  of  load  statements  causing  the  flow   •  Loop  iteraMon  constraints   –  Flows-­‐in  valid  only  if  the  corresponding  Flows-­‐out  occurs  in   an  earlier  iteraMon   •  On-­‐demand  analysis  using  context-­‐free  language  bject   (i+1)-­‐th  itera,on   load /prev   outside  o reachability  to  match  store/load  and  Transaction1! call/return   Order4,i! 11 33   i-­‐th  itera,on   store16/prev  
  • 34. StaMc  Analysis  Outline   •  Object:  pair  of  allocaMon  site  and  calling  context   •  Flows-­‐out  path   –  Loop  object  escaping  to  outside  object   –  Sequence  of  store  statements  for  the  flow   •  Flows-­‐in  path   –  Escaping  object  flows  from  outside  object  into  the  loop   –  Sequence  of  load  statements  causing  the  flow   •  Loop  iteraMon  constraints   –  Flows-­‐in  valid  only  if  the  corresponding  Flows-­‐out  occurs  in   an  earlier  iteraMon   –  Captured  b analysis  u recency  abstracMon   ERA)   •  On-­‐demand  y  extended  sing  context-­‐free  l(anguage   reachability  to  match  store/load  and  call/return   34  
  • 35. StaMc  Analysis  Outline  (cont.)   •  On-­‐demand  analysis   –  Detect  leaks  only  for  objects  allocated  in  specified  loops   –  Context-­‐free  language  reachability  to  match  relevant  store/ load  and  call/return   •  ConservaMve  handling  of  thread  lifeMme   –  Assume  the  lifeMme  of  each  thread  exceeds  the  loop  lifeMme   –  Capture  objects  leaking  to  long-­‐running  threads   35  
  • 36. Analysis  ImplementaMon   •  Memory  leak   –  An  object  leaks  if  it  starts  a  flows-­‐out  path,  but  does  not  have   a  matching  flows-­‐in  path   •  ReporMng  leaks   –  Leaking  object,  with  calling  context  of  its  allocaMon   –  Outside  target  object,  with  calling  context  of  its  allocaMon   –  Escape-­‐causing  heap  write  (store)  statement,  with  its  calling   context   •  LeakChecker:  leak  detecMon  tool  built  using  Soot     36  
  • 37. EvaluaMon   •  8  real-­‐world  Java  programs   –  Enterprise  trading,  so5ware  tools,  databases,  logging   –  3  programs  never  studied  by  exisMng  work   •  EffecMve  for  leak  detecMon?   –  LeakChecker  detected  both  known  and  new  leaks   •  Suitable  for  pracMcal  use?   –  Analysis  running  Mme  (all  <  35  mins)   –  Reasonable  false  posiMve  rate  (avg  <  50%)   •  Case  studies   37   –  Performed  to  understand  quality  of  leak  report   –  For  each  leak  defect,  pinpoint  root  cause  and  fix  the  problem   in  <  2  hours  
  • 38. Eclipse  Diff   •  Scenario:  compare  two  large  JAR  files   –  runCompare  method  in  compare  plugin! –  An  arMficial  loop  to  invoke  runCompare  mulMple  Mmes   •  Loop  objects   –  Editor:  display  comparison  results   –  HistoryEntry:  represent  list  of  opened  editors,  and  allow   users  to  navigate  them  backward/forward   •  Outside  object   –  History:  managed  by  another  plugin  to  save  HistoryEntry     38   compare  plugin   !!!! Editor! loop  objects   history  plugin   HistoryEntry! History! outside  object  
  • 39. Conclusions   •  LeakChecker  is  both  effecMve  and  pracMcal   •  Key  insights   –  Capture  common  paVerns  of  leaking  behavior   –  Focus  on  user-­‐specified  event  loops   –  Report  leaks  with  detailed  context  informaMon     39  
  • 40. Thank    you   40