SlideShare une entreprise Scribd logo
1  sur  14
Télécharger pour lire hors ligne
Memory Leaks in Java
By Tanmayee Sahoo
Presentation Outline
Introduction

Symptoms of memory leak

Detecting memory leak

Preventing memory leak

Question and Answer


1
Introduction
In procedural language like C, before a developer
uses a variable he/she has to manually allocate a
region in the memory where the value will reside and
once the application finishes using that value, the
region of the memory must be manually freed by
writing the code for this. But in java when a
developer creates an object using the key word new
JVM automatically allocates the memory for that
object.
2
Introduction (cont…)
During the life of the application JVM keeps on check
which objects in memory are in use and which are not
at a regular interval. Unused objects can be freed and
memory occupied by the object can be reclaimed and
reused. This process is called garbage collection and
the corresponding piece of JVM is called garbage
collector. Memory Leak in java is a situation when
some of the objects are not used by the application
3
Introduction (cont…)
any more but GC failed to recognize them as unused
there by the unused objects remain in the memory
indefinitely and the amount of memory available to
the application is reduced.

4
Symptoms of memory leak
When an application has memory leak we will notice
the following things.
 Memory usage consistently increases during the
application life span. Sooner or later the application
will crash because of out of memory.
 Performance consistently decreases.

5
Detecting memory leak
Several tools are available to detect
memory leak in a java application such
as:
 Yourkit
 Jprofiler
 Visual VM
 AppPerfect
 JProbe
6
Preventing memory leak

While writing code if we can take care of a few
points we can avoid memory leak.
 Avoid String Concatenation. Use StringBuilder.
 Avoid unnecessary object creation.

7
Preventing memory leak (Cont…)
Static Objects : By default live for the entire life of
the application unless explicitly set to null. So it is
better to set the references to null once the use the
static member is over.
 Avoid Using System.gc()


8
Preventing memory leak (Cont…)





9

Close ResultSet, Statement and Connection objects
in finally block.
Unregister Event listener class.
Disable Jsp Page buffer if you are not using jsp
feature that needs buffering so that performance will
improve as memory will not be used in creating
buffer and output will go directly to the browser.
Preventing memory leak (Cont…)



Set session = false in the jsp page if the page is not
accessing the data from the session.



Avoid storing huge data in the session.



Invalidate the session when no longer used.

Avoid duplicating libraries. For ex. If a library is
shared among multiple modules in the same
application then use WAR file manifest's
CLASSPATH to share the libraries instead of



11
Preventing memory leak (Cont…)
Duplicating the library in the WEB-INF/lib of
each module.


12

Set session timeout appropriately.
Question and Answer

??
13
Thank You
14

Contenu connexe

Tendances

Let's talk about Garbage Collection
Let's talk about Garbage CollectionLet's talk about Garbage Collection
Let's talk about Garbage CollectionHaim Yadid
 
Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)Prashanth Kumar
 
Yocto Project ハンズオン プレゼン用資料
Yocto Project ハンズオン プレゼン用資料Yocto Project ハンズオン プレゼン用資料
Yocto Project ハンズオン プレゼン用資料Nobuhiro Iwamatsu
 
Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)
Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)
Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)CODE WHITE GmbH
 
Linux power management: are you doing it right?
Linux power management: are you doing it right?Linux power management: are you doing it right?
Linux power management: are you doing it right?Chris Simmonds
 
Linux Kernel MMC Storage driver Overview
Linux Kernel MMC Storage driver OverviewLinux Kernel MMC Storage driver Overview
Linux Kernel MMC Storage driver OverviewRajKumar Rampelli
 
Building CICD Pipelines for Serverless Applications
Building CICD Pipelines for Serverless ApplicationsBuilding CICD Pipelines for Serverless Applications
Building CICD Pipelines for Serverless ApplicationsAmazon Web Services
 
Java Performance and Profiling
Java Performance and ProfilingJava Performance and Profiling
Java Performance and ProfilingWSO2
 
Ruxcon 2014 - Stefan Esser - iOS8 Containers, Sandboxes and Entitlements
Ruxcon 2014 - Stefan Esser - iOS8 Containers, Sandboxes and EntitlementsRuxcon 2014 - Stefan Esser - iOS8 Containers, Sandboxes and Entitlements
Ruxcon 2014 - Stefan Esser - iOS8 Containers, Sandboxes and EntitlementsStefan Esser
 
9 Real Life Applications of Java
9 Real Life Applications of Java9 Real Life Applications of Java
9 Real Life Applications of JavaPrachiVarshney7
 
Coredns nodecache - A highly-available Node-cache DNS server
Coredns nodecache - A highly-available Node-cache DNS serverCoredns nodecache - A highly-available Node-cache DNS server
Coredns nodecache - A highly-available Node-cache DNS serverYann Hamon
 
Android Storage - StorageManager & OBB
Android Storage - StorageManager & OBBAndroid Storage - StorageManager & OBB
Android Storage - StorageManager & OBBWilliam Lee
 
Exceptionhandling
ExceptionhandlingExceptionhandling
ExceptionhandlingNuha Noor
 
Cross platform mobile development
Cross platform mobile developmentCross platform mobile development
Cross platform mobile developmentPeter Friese
 

Tendances (20)

Let's talk about Garbage Collection
Let's talk about Garbage CollectionLet's talk about Garbage Collection
Let's talk about Garbage Collection
 
Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)
 
Yocto Project ハンズオン プレゼン用資料
Yocto Project ハンズオン プレゼン用資料Yocto Project ハンズオン プレゼン用資料
Yocto Project ハンズオン プレゼン用資料
 
Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)
Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)
Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)
 
Linux power management: are you doing it right?
Linux power management: are you doing it right?Linux power management: are you doing it right?
Linux power management: are you doing it right?
 
Linux Kernel MMC Storage driver Overview
Linux Kernel MMC Storage driver OverviewLinux Kernel MMC Storage driver Overview
Linux Kernel MMC Storage driver Overview
 
Phone gap
Phone gapPhone gap
Phone gap
 
Building CICD Pipelines for Serverless Applications
Building CICD Pipelines for Serverless ApplicationsBuilding CICD Pipelines for Serverless Applications
Building CICD Pipelines for Serverless Applications
 
Java Performance and Profiling
Java Performance and ProfilingJava Performance and Profiling
Java Performance and Profiling
 
Ruxcon 2014 - Stefan Esser - iOS8 Containers, Sandboxes and Entitlements
Ruxcon 2014 - Stefan Esser - iOS8 Containers, Sandboxes and EntitlementsRuxcon 2014 - Stefan Esser - iOS8 Containers, Sandboxes and Entitlements
Ruxcon 2014 - Stefan Esser - iOS8 Containers, Sandboxes and Entitlements
 
Hacking Android OS
Hacking Android OSHacking Android OS
Hacking Android OS
 
9 Real Life Applications of Java
9 Real Life Applications of Java9 Real Life Applications of Java
9 Real Life Applications of Java
 
Practice of Android Reverse Engineering
Practice of Android Reverse EngineeringPractice of Android Reverse Engineering
Practice of Android Reverse Engineering
 
Gdb cheat sheet
Gdb cheat sheetGdb cheat sheet
Gdb cheat sheet
 
Coredns nodecache - A highly-available Node-cache DNS server
Coredns nodecache - A highly-available Node-cache DNS serverCoredns nodecache - A highly-available Node-cache DNS server
Coredns nodecache - A highly-available Node-cache DNS server
 
Java GC
Java GCJava GC
Java GC
 
Android Storage - StorageManager & OBB
Android Storage - StorageManager & OBBAndroid Storage - StorageManager & OBB
Android Storage - StorageManager & OBB
 
Exceptionhandling
ExceptionhandlingExceptionhandling
Exceptionhandling
 
Cross platform mobile development
Cross platform mobile developmentCross platform mobile development
Cross platform mobile development
 
Android studio
Android studioAndroid studio
Android studio
 

En vedette

Be happy! Счастье - это просто выбор.
Be happy! Счастье - это просто выбор.Be happy! Счастье - это просто выбор.
Be happy! Счастье - это просто выбор.Alena Simonova
 
Sun jdk 1.6内存管理 -使用篇
Sun jdk 1.6内存管理 -使用篇Sun jdk 1.6内存管理 -使用篇
Sun jdk 1.6内存管理 -使用篇bluedavy lin
 
O femeie manager in cariera | www.mototol.ro |
O femeie manager in cariera | www.mototol.ro |O femeie manager in cariera | www.mototol.ro |
O femeie manager in cariera | www.mototol.ro |Mototol Romania
 
Digital and customer experience: slides from CXFS - Antony Mayfield, Brillian...
Digital and customer experience: slides from CXFS - Antony Mayfield, Brillian...Digital and customer experience: slides from CXFS - Antony Mayfield, Brillian...
Digital and customer experience: slides from CXFS - Antony Mayfield, Brillian...Antony Mayfield
 
Performance optimization techniques for Java code
Performance optimization techniques for Java codePerformance optimization techniques for Java code
Performance optimization techniques for Java codeAttila Balazs
 
(MBL314) Build World-Class Cloud-Connected Products: Sonos
(MBL314) Build World-Class Cloud-Connected Products: Sonos(MBL314) Build World-Class Cloud-Connected Products: Sonos
(MBL314) Build World-Class Cloud-Connected Products: SonosAmazon Web Services
 
Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance TuningMinh Hoang
 
Administracion de Documentos Electronicos - Modelo de Gestión Documental MGD-RTA
Administracion de Documentos Electronicos - Modelo de Gestión Documental MGD-RTAAdministracion de Documentos Electronicos - Modelo de Gestión Documental MGD-RTA
Administracion de Documentos Electronicos - Modelo de Gestión Documental MGD-RTAHiriam Eduardo Perez Vidal
 
Kettle Chips revamp
Kettle Chips revamp Kettle Chips revamp
Kettle Chips revamp nwright2016
 
Utz integrated mktg presentation
Utz integrated mktg presentationUtz integrated mktg presentation
Utz integrated mktg presentationDejan Djordjevic
 
Duterte cabinet secretary
Duterte cabinet secretaryDuterte cabinet secretary
Duterte cabinet secretaryArvin Dela Cruz
 
Introduction of Java GC Tuning and Java Java Mission Control
Introduction of Java GC Tuning and Java Java Mission ControlIntroduction of Java GC Tuning and Java Java Mission Control
Introduction of Java GC Tuning and Java Java Mission ControlLeon Chen
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance TunningTerry Cho
 
Brands in the digital age - Google Squared
Brands in the digital age - Google SquaredBrands in the digital age - Google Squared
Brands in the digital age - Google SquaredAntony Mayfield
 
The Art of Social Media in Asia Pacific with Guy Kawasaki
The Art of Social Media in Asia Pacific with Guy KawasakiThe Art of Social Media in Asia Pacific with Guy Kawasaki
The Art of Social Media in Asia Pacific with Guy KawasakiHubSpot
 
PSFK Technology Debrief: Virtual Reality
PSFK Technology Debrief: Virtual RealityPSFK Technology Debrief: Virtual Reality
PSFK Technology Debrief: Virtual RealityPSFK
 

En vedette (20)

Be happy! Счастье - это просто выбор.
Be happy! Счастье - это просто выбор.Be happy! Счастье - это просто выбор.
Be happy! Счастье - это просто выбор.
 
Sun jdk 1.6内存管理 -使用篇
Sun jdk 1.6内存管理 -使用篇Sun jdk 1.6内存管理 -使用篇
Sun jdk 1.6内存管理 -使用篇
 
Quality of Health Care
Quality of Health CareQuality of Health Care
Quality of Health Care
 
O femeie manager in cariera | www.mototol.ro |
O femeie manager in cariera | www.mototol.ro |O femeie manager in cariera | www.mototol.ro |
O femeie manager in cariera | www.mototol.ro |
 
Digital and customer experience: slides from CXFS - Antony Mayfield, Brillian...
Digital and customer experience: slides from CXFS - Antony Mayfield, Brillian...Digital and customer experience: slides from CXFS - Antony Mayfield, Brillian...
Digital and customer experience: slides from CXFS - Antony Mayfield, Brillian...
 
Performance optimization techniques for Java code
Performance optimization techniques for Java codePerformance optimization techniques for Java code
Performance optimization techniques for Java code
 
Asynchronous PHP. Myth? Reality!
Asynchronous PHP. Myth? Reality!Asynchronous PHP. Myth? Reality!
Asynchronous PHP. Myth? Reality!
 
(MBL314) Build World-Class Cloud-Connected Products: Sonos
(MBL314) Build World-Class Cloud-Connected Products: Sonos(MBL314) Build World-Class Cloud-Connected Products: Sonos
(MBL314) Build World-Class Cloud-Connected Products: Sonos
 
Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance Tuning
 
Memory leak
Memory leakMemory leak
Memory leak
 
Administracion de Documentos Electronicos - Modelo de Gestión Documental MGD-RTA
Administracion de Documentos Electronicos - Modelo de Gestión Documental MGD-RTAAdministracion de Documentos Electronicos - Modelo de Gestión Documental MGD-RTA
Administracion de Documentos Electronicos - Modelo de Gestión Documental MGD-RTA
 
Kettle Chips revamp
Kettle Chips revamp Kettle Chips revamp
Kettle Chips revamp
 
Utz integrated mktg presentation
Utz integrated mktg presentationUtz integrated mktg presentation
Utz integrated mktg presentation
 
Duterte cabinet secretary
Duterte cabinet secretaryDuterte cabinet secretary
Duterte cabinet secretary
 
Introduction of Java GC Tuning and Java Java Mission Control
Introduction of Java GC Tuning and Java Java Mission ControlIntroduction of Java GC Tuning and Java Java Mission Control
Introduction of Java GC Tuning and Java Java Mission Control
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunning
 
Brands in the digital age - Google Squared
Brands in the digital age - Google SquaredBrands in the digital age - Google Squared
Brands in the digital age - Google Squared
 
The Art of Social Media in Asia Pacific with Guy Kawasaki
The Art of Social Media in Asia Pacific with Guy KawasakiThe Art of Social Media in Asia Pacific with Guy Kawasaki
The Art of Social Media in Asia Pacific with Guy Kawasaki
 
River profile
River profileRiver profile
River profile
 
PSFK Technology Debrief: Virtual Reality
PSFK Technology Debrief: Virtual RealityPSFK Technology Debrief: Virtual Reality
PSFK Technology Debrief: Virtual Reality
 

Similaire à Memory Leaks in Java - Detect, Prevent and Tools

performance optimization: Memory
performance optimization: Memoryperformance optimization: Memory
performance optimization: Memory晓东 杜
 
Detecting Memory Leaks in Android App
Detecting Memory Leaks in Android AppDetecting Memory Leaks in Android App
Detecting Memory Leaks in Android AppDinesh Prajapati
 
ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...
ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...
ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...Padma shree. T
 
Efficient Memory and Thread Management in Highly Parallel Java Applications
Efficient Memory and Thread Management in Highly Parallel Java ApplicationsEfficient Memory and Thread Management in Highly Parallel Java Applications
Efficient Memory and Thread Management in Highly Parallel Java Applicationspkoza
 
Profiling JavaScript Performance
Profiling JavaScript PerformanceProfiling JavaScript Performance
Profiling JavaScript PerformanceNoam Kfir
 
Efficient Memory and Thread Management in Highly Parallel Java Applications
Efficient Memory and Thread Management in Highly Parallel Java ApplicationsEfficient Memory and Thread Management in Highly Parallel Java Applications
Efficient Memory and Thread Management in Highly Parallel Java ApplicationsPhillip Koza
 
Memory Leaks in Android Applications
Memory Leaks in Android ApplicationsMemory Leaks in Android Applications
Memory Leaks in Android ApplicationsLokesh Ponnada
 
Memory Heap Analysis with AppDynamics - AppSphere16
Memory Heap Analysis with AppDynamics - AppSphere16Memory Heap Analysis with AppDynamics - AppSphere16
Memory Heap Analysis with AppDynamics - AppSphere16AppDynamics
 
MC0078 SMU 2013 Fall session
MC0078 SMU 2013 Fall sessionMC0078 SMU 2013 Fall session
MC0078 SMU 2013 Fall sessionNarinder Kumar
 
Postmortem of a uwp xaml application development
Postmortem of a uwp xaml application developmentPostmortem of a uwp xaml application development
Postmortem of a uwp xaml application developmentDavid Catuhe
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTIONProf Ansari
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTIONProf Ansari
 
Short notes of oop with java
Short notes of oop with javaShort notes of oop with java
Short notes of oop with javaMohamed Fathy
 
Garbage Collection, Tuning And Monitoring JVM In EBS 11i And R12
Garbage Collection, Tuning And Monitoring JVM In EBS 11i And R12Garbage Collection, Tuning And Monitoring JVM In EBS 11i And R12
Garbage Collection, Tuning And Monitoring JVM In EBS 11i And R12sidg75
 
20 most important java programming interview questions
20 most important java programming interview questions20 most important java programming interview questions
20 most important java programming interview questionsGradeup
 
TechGIG_Memory leaks in_java_webnair_26th_july_2012
TechGIG_Memory leaks in_java_webnair_26th_july_2012TechGIG_Memory leaks in_java_webnair_26th_july_2012
TechGIG_Memory leaks in_java_webnair_26th_july_2012Ashish Bhasin
 
Library Managemnet System
Library Managemnet SystemLibrary Managemnet System
Library Managemnet SystemAbhishek Shakya
 

Similaire à Memory Leaks in Java - Detect, Prevent and Tools (20)

performance optimization: Memory
performance optimization: Memoryperformance optimization: Memory
performance optimization: Memory
 
Detecting Memory Leaks in Android App
Detecting Memory Leaks in Android AppDetecting Memory Leaks in Android App
Detecting Memory Leaks in Android App
 
ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...
ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...
ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...
 
Efficient Memory and Thread Management in Highly Parallel Java Applications
Efficient Memory and Thread Management in Highly Parallel Java ApplicationsEfficient Memory and Thread Management in Highly Parallel Java Applications
Efficient Memory and Thread Management in Highly Parallel Java Applications
 
Profiling JavaScript Performance
Profiling JavaScript PerformanceProfiling JavaScript Performance
Profiling JavaScript Performance
 
Efficient Memory and Thread Management in Highly Parallel Java Applications
Efficient Memory and Thread Management in Highly Parallel Java ApplicationsEfficient Memory and Thread Management in Highly Parallel Java Applications
Efficient Memory and Thread Management in Highly Parallel Java Applications
 
Memory Leaks in Android Applications
Memory Leaks in Android ApplicationsMemory Leaks in Android Applications
Memory Leaks in Android Applications
 
Android Memory Management
Android Memory ManagementAndroid Memory Management
Android Memory Management
 
Memory Heap Analysis with AppDynamics - AppSphere16
Memory Heap Analysis with AppDynamics - AppSphere16Memory Heap Analysis with AppDynamics - AppSphere16
Memory Heap Analysis with AppDynamics - AppSphere16
 
MC0078 SMU 2013 Fall session
MC0078 SMU 2013 Fall sessionMC0078 SMU 2013 Fall session
MC0078 SMU 2013 Fall session
 
Postmortem of a uwp xaml application development
Postmortem of a uwp xaml application developmentPostmortem of a uwp xaml application development
Postmortem of a uwp xaml application development
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTION
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTION
 
Short notes of oop with java
Short notes of oop with javaShort notes of oop with java
Short notes of oop with java
 
Javasession10
Javasession10Javasession10
Javasession10
 
Garbage Collection, Tuning And Monitoring JVM In EBS 11i And R12
Garbage Collection, Tuning And Monitoring JVM In EBS 11i And R12Garbage Collection, Tuning And Monitoring JVM In EBS 11i And R12
Garbage Collection, Tuning And Monitoring JVM In EBS 11i And R12
 
20 most important java programming interview questions
20 most important java programming interview questions20 most important java programming interview questions
20 most important java programming interview questions
 
TechGIG_Memory leaks in_java_webnair_26th_july_2012
TechGIG_Memory leaks in_java_webnair_26th_july_2012TechGIG_Memory leaks in_java_webnair_26th_july_2012
TechGIG_Memory leaks in_java_webnair_26th_july_2012
 
CAR SHOWROOM SYSTEM
CAR SHOWROOM SYSTEMCAR SHOWROOM SYSTEM
CAR SHOWROOM SYSTEM
 
Library Managemnet System
Library Managemnet SystemLibrary Managemnet System
Library Managemnet System
 

Plus de Mindfire Solutions (20)

Physician Search and Review
Physician Search and ReviewPhysician Search and Review
Physician Search and Review
 
diet management app
diet management appdiet management app
diet management app
 
Business Technology Solution
Business Technology SolutionBusiness Technology Solution
Business Technology Solution
 
Remote Health Monitoring
Remote Health MonitoringRemote Health Monitoring
Remote Health Monitoring
 
Influencer Marketing Solution
Influencer Marketing SolutionInfluencer Marketing Solution
Influencer Marketing Solution
 
ELMAH
ELMAHELMAH
ELMAH
 
High Availability of Azure Applications
High Availability of Azure ApplicationsHigh Availability of Azure Applications
High Availability of Azure Applications
 
IOT Hands On
IOT Hands OnIOT Hands On
IOT Hands On
 
Glimpse of Loops Vs Set
Glimpse of Loops Vs SetGlimpse of Loops Vs Set
Glimpse of Loops Vs Set
 
Oracle Sql Developer-Getting Started
Oracle Sql Developer-Getting StartedOracle Sql Developer-Getting Started
Oracle Sql Developer-Getting Started
 
Adaptive Layout In iOS 8
Adaptive Layout In iOS 8Adaptive Layout In iOS 8
Adaptive Layout In iOS 8
 
Introduction to Auto-layout : iOS/Mac
Introduction to Auto-layout : iOS/MacIntroduction to Auto-layout : iOS/Mac
Introduction to Auto-layout : iOS/Mac
 
LINQPad - utility Tool
LINQPad - utility ToolLINQPad - utility Tool
LINQPad - utility Tool
 
Get started with watch kit development
Get started with watch kit developmentGet started with watch kit development
Get started with watch kit development
 
Swift vs Objective-C
Swift vs Objective-CSwift vs Objective-C
Swift vs Objective-C
 
Material Design in Android
Material Design in AndroidMaterial Design in Android
Material Design in Android
 
Introduction to OData
Introduction to ODataIntroduction to OData
Introduction to OData
 
Ext js Part 2- MVC
Ext js Part 2- MVCExt js Part 2- MVC
Ext js Part 2- MVC
 
ExtJs Basic Part-1
ExtJs Basic Part-1ExtJs Basic Part-1
ExtJs Basic Part-1
 
Spring Security Introduction
Spring Security IntroductionSpring Security Introduction
Spring Security Introduction
 

Dernier

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
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
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 

Dernier (20)

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
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
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 

Memory Leaks in Java - Detect, Prevent and Tools

  • 1. Memory Leaks in Java By Tanmayee Sahoo
  • 2. Presentation Outline Introduction  Symptoms of memory leak  Detecting memory leak  Preventing memory leak  Question and Answer  1
  • 3. Introduction In procedural language like C, before a developer uses a variable he/she has to manually allocate a region in the memory where the value will reside and once the application finishes using that value, the region of the memory must be manually freed by writing the code for this. But in java when a developer creates an object using the key word new JVM automatically allocates the memory for that object. 2
  • 4. Introduction (cont…) During the life of the application JVM keeps on check which objects in memory are in use and which are not at a regular interval. Unused objects can be freed and memory occupied by the object can be reclaimed and reused. This process is called garbage collection and the corresponding piece of JVM is called garbage collector. Memory Leak in java is a situation when some of the objects are not used by the application 3
  • 5. Introduction (cont…) any more but GC failed to recognize them as unused there by the unused objects remain in the memory indefinitely and the amount of memory available to the application is reduced. 4
  • 6. Symptoms of memory leak When an application has memory leak we will notice the following things.  Memory usage consistently increases during the application life span. Sooner or later the application will crash because of out of memory.  Performance consistently decreases. 5
  • 7. Detecting memory leak Several tools are available to detect memory leak in a java application such as:  Yourkit  Jprofiler  Visual VM  AppPerfect  JProbe 6
  • 8. Preventing memory leak While writing code if we can take care of a few points we can avoid memory leak.  Avoid String Concatenation. Use StringBuilder.  Avoid unnecessary object creation. 7
  • 9. Preventing memory leak (Cont…) Static Objects : By default live for the entire life of the application unless explicitly set to null. So it is better to set the references to null once the use the static member is over.  Avoid Using System.gc()  8
  • 10. Preventing memory leak (Cont…)    9 Close ResultSet, Statement and Connection objects in finally block. Unregister Event listener class. Disable Jsp Page buffer if you are not using jsp feature that needs buffering so that performance will improve as memory will not be used in creating buffer and output will go directly to the browser.
  • 11. Preventing memory leak (Cont…)  Set session = false in the jsp page if the page is not accessing the data from the session.  Avoid storing huge data in the session.  Invalidate the session when no longer used. Avoid duplicating libraries. For ex. If a library is shared among multiple modules in the same application then use WAR file manifest's CLASSPATH to share the libraries instead of  11
  • 12. Preventing memory leak (Cont…) Duplicating the library in the WEB-INF/lib of each module.  12 Set session timeout appropriately.