Upload
aditya-thatte
View
3.683
Download
3
Embed Size (px)
DESCRIPTION
Citation preview
Static Memory Leak Detector (For C language)
Dalbhide BipinJoshi AshwinThatte Aditya
Mentor Mentor
Prof. Sase Mr.Umesh Nachan
KPIT Infosystems
AgendaMemory LeaksMemory Leak ScenariosCauses of Memory LeaksScope Components / ModulesCode SnippetAdvantage of SMLD
Memory Leaks ?
“Unintentional” memory consumption
Memory is not lost “physically”
Symptoms include “reduced performance” , “failure”
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.
Causes…
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 )
Block schematic ( modules)
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 :-
Advantages :- Memory leaks detected at “compile time”
Saves valuable time ( debugging )
Helps in saving precious memory
Enhances performance
Challenges
Parsing “C” language
Plugging this tool into existing “C” compiler
References
Principles of Compilers - Aho / Ulmann
LEX YACC - O’ Reilly
Questions