Top Banner
Static Memory Leak Detector (For C language) Dalbhide Bipin Joshi Ashwin Thatte Aditya Mentor Mentor Prof. Sase Mr.Umesh Nachan KPIT Infosystems
15

Static Memory Leak Detector

Apr 24, 2015

Download

Technology

Aditya Thatte

 
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Static Memory Leak Detector

Static Memory Leak Detector (For C language)

Dalbhide BipinJoshi AshwinThatte Aditya

Mentor Mentor

Prof. Sase Mr.Umesh Nachan

KPIT Infosystems

Page 2: Static Memory Leak Detector

AgendaMemory LeaksMemory Leak ScenariosCauses of Memory LeaksScope Components / ModulesCode SnippetAdvantage of SMLD

Page 3: Static Memory Leak Detector

Memory Leaks ?

“Unintentional” memory consumption

Memory is not lost “physically”

Symptoms include “reduced performance” , “failure”

Page 4: Static Memory Leak Detector

Memory leak scenarios Cases where leaks are serious :-

1.where program is left running, and consumes more memory over time ( eg . Daemons , servers )2.where new memory is allocated frequently ( intentional)3.where memory is very limited e.g. in an embedded system

4. where running on operating systems (such as AmigaOS) where memory may not be automatically released on termination

Existing tools :-mtrace, dmalloc, memwatch all detect memory leaks at run time.

Page 5: Static Memory Leak Detector

Causes…

Page 6: Static Memory Leak Detector
Page 7: Static Memory Leak Detector

Scope

Parsing C and generating symbol tables

Tracing and validating memory allocations and deallocations

(malloc (), free () )

Generate report of memory leaks.( warnings , line by line analysis )

Page 8: Static Memory Leak Detector

Block schematic ( modules)

Page 9: Static Memory Leak Detector
Page 10: Static Memory Leak Detector

id name type scope arguments return_type1 add decla 0 int *, int * void 2 frees decla 0 int *, int * void 3 main defi 0 void 4 p1 int * 35 p2 int * 36 p3 int * 37 add ref 3 4,5 void 8 frees ref 3 5,6 void 9 add defi 0 10,11 void 10 p int ** 911 q int ** 912 i int 913 j int 914 for iter 915 for iter 1416 malloc func 15 int int *17 malloc func 15 int int *18 frees defi 0 19,20 void 19 p int * 1820 q int * 1821 free func 1822 free func 18

Symbol table :-

Page 11: Static Memory Leak Detector
Page 12: Static Memory Leak Detector

Advantages :- Memory leaks detected at “compile time”

Saves valuable time ( debugging )

Helps in saving precious memory

Enhances performance

Page 13: Static Memory Leak Detector

Challenges

Parsing “C” language

Plugging this tool into existing “C” compiler

Page 14: Static Memory Leak Detector

References

Principles of Compilers - Aho / Ulmann

LEX YACC - O’ Reilly

Page 15: Static Memory Leak Detector

Questions