1 Maximize Java Performance by using YOURKIT with uPortal development Faizan Ahmed – Sr. Application Developer.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 5 Array and Collections.
Advertisements

Introduction to Java 2 Programming Lecture 3 Writing Java Applications, Java Development Tools.
Module R2 CS450. Next Week R1 is due next Friday ▫Bring manuals in a binder - make sure to have a cover page with group number, module, and date. You.
Java Virtual Machine (JVM). Lecture Objectives Learn about the Java Virtual Machine (JVM) Understand the functionalities of the class loader subsystem.
Designing an ADT The design of an ADT should evolve naturally during the problem-solving process Questions to ask when designing an ADT What data does.
Java Memory Management Charles-François THUEUX Sitraka Inc.
From Theory to Practice 2 OOP Overview Performance issues: –Preparing classes for inheritance –Memory management and release of obsolete object.
Various languages….  Could affect performance  Could affect reliability  Could affect language choice.
Chapter 10 Introduction to Arrays
Chapter 15 Memory Management: Four main memory areas for a C++ program: Code: code for instructions, methods, etc. static data: Global variables (declared.
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Lifetime “The lifetime of a variable is the time during which the variable is bound to a specific memory location.” [p. 219] “…the lifetime of a variable.
Java Virtual Machine (JVM). Lecture Objectives Learn about the Java Virtual Machine (JVM) Understand the functionalities of the class loader subsystem.
Programming in Java CSE301 Half Lecture Harry Erwin, PhD University of Sunderland.
Structured Programming and UML Overview Session 2 LBSC 790 / INFM 718B Building the Human-Computer Interface.
Introduction to Java A lab course by Dr. Junaid Ahmed Zubairi SUNY Fredonia.
Unit 061 Java Virtual Machine (JVM) What is Java Virtual Machine? The Class Loader Subsystem Linking oVerification oPreparation oResolution Class Initialization.
Garbage Collection CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Java Security. Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security Manager.
Classes, Objects, Arrays, Collections and Autoboxing Dr. Andrew Wallace PhD BEng(hons) EurIng
Java and C++, The Difference An introduction Unit - 00.
Java Programming Robert Chatley William Lee
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
EE4E. C++ Programming Lecture 1 From C to C++. Contents Introduction Introduction Variables Variables Pointers and references Pointers and references.
CSC3315 (Spring 2009)1 CSC 3315 Programming Languages Hamid Harroud School of Science and Engineering, Akhawayn University
Object Oriented Programming: Java Edition By: Samuel Robinson.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Arrays An array is a data structure that consists of an ordered collection of similar items (where “similar items” means items of the same type.) An array.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 15: More-Advanced Concepts.
Problem of the Day  Why are manhole covers round?
Basic Semantics Associating meaning with language entities.
Chapter 2: Java Fundamentals
A First Simple Program /* This is a simple Java program. Call this file "Example.java".*/ class Example { // Your program begins with a call to main().
Plug-In Architecture Pattern. Problem The functionality of a system needs to be extended after the software is shipped The set of possible post-shipment.
Java development environment and Review of Java. Eclipse TM Intergrated Development Environment (IDE) Running Eclipse: Warning: Never check the “Use this.
1 Introduction to Software Testing. Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Chapter 1 2.
Chapter 7 Pointers: Java does not have pointers. Used for dynamic memory allocation.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
JAVA COURSE 1 Computer Engineering Association. Compile your first program Public class Hello{ public class Hello(){ System.out.println(“Hello”); } puclic.
Everything is an object (CH-2) Manipulating Objects with References. Manipulating Objects with References. String s; String s = “IS2550” String s = new.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Java Basics Opening Discussion zWhat did we talk about last class? zWhat are the basic constructs in the programming languages you are familiar.
CS170 ygao JAVA, C4Slide 1. CS170 ygao JAVA, C4Slide 2.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Reference Types CSE301 University of Sunderland Harry R Erwin, PhD.
CPSC 372 John D. McGregor Module 1 Session 2 Process Measurement.
Creating Java Applications (Software Development Life Cycle) 1. specify the problem requirements - clarify 2. analyze the problem - Input? Processes? Output.
Memory Management in Java Mr. Gerb Computer Science 4.
CS 201 Lecture 1 (b) Using an IDE Tarik Booker CS 201: Introduction to Programming California State University, Los Angeles.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
Chapter 8 Arrays and the ArrayList Class Arrays of Objects.
Design issues for Object-Oriented Languages
Object Lifetime and Pointers
Lecture 6 Object Oriented Programming Using Java
Chapter No. : 1 Introduction to Java.
Chapter 2 Elementary Programming
Compositional Pointer and Escape Analysis for Java Programs
Dynamically Allocated Memory
An Introduction to Java – Part I, language basics
Object-Oriented Software Engineering
CLEANING UP UNUSED OBJECTS
Arrays in Java.
Variables and Java vs C++
C. M. Overstreet Old Dominion University Fall 2005
SPL – PS2 C++ Memory Handling.
Plug-In Architecture Pattern
Presentation transcript:

1 Maximize Java Performance by using YOURKIT with uPortal development Faizan Ahmed – Sr. Application Developer

2 Overview  Why memory related issues are problem?  Introduction to YourKit.  Some terms  What is Java Memory Leak?  Find and resolve memory leak (demo)  Some code tips.

3 Why memory related issues can be performance problem?  Memory-related issues affect execution speed and reliability of application.

4 Getting started with YourKit  Download and extract the zip file.  Set PATH to dll \bin\win32  Check installation java -Xrunyjpagent:help  IDE configuration Plug-in installation Enable action group “profile” Windows| customize perspective| commands  Agent configuration -agentlib:yjpagent

5 Snapshots  YourKit investigative model is based upon snapshots which capture the state of the application at specific points in time.

6 Dynamic Nature of a RootSet  Root Set is a set of foundational object references within your application public class uPortal { private static uPortal portal = null; public static void main(String args[]){ portal = new uPortal(); portal.method1(); } Root Set: uPortal portal String[] args

7 Dynamic Nature of a RootSet Private void method1 { FooObject fooObject = new FooObject(); …….. } Root Set: uPortal portal String[] args FooObject fooObject

8 Dynamic Nature of a RootSet public class uPortal { private static uPortal portal = null; public static void main(String args[]){ portal = new uPortal(); portal.method1(); …. } Root Set: uPortal portal String[] args

9 What is Memory leak in Java?  Occurs when objects that have outlived their usefulness to the application remain within the heap through successive garbage collections

10 What is a memory leak in Java?  We can extend the set of object states to three: Allocated Exists within the JVM’s heap Reachable A path exists (directly or indirectly) from a member of the root set, through a sequence of references to that object. Live From the intent of the application design the program will use the object.

11 What is memory leak in java? Java Memory leak Allocated Reachable Live Handled by JVM

12 What are loitered Objects?  Loitered objects are reachable, but they are not live.

13 Most common memory leak causes  Failure to remove Stale Object References from Data Structures.  Lingering Transitional references. A reference to a short-term object is used transiently by a long-term object but the long-term object does not clear the reference when it’s done with it.

14 Preparing for your investigation Have a firm conceptual grasp of the architecture of the application you are about to analyze. An attitude that you can find, and resolve, the underlying problem.

15 How to find leaked Objects?  By Comparing snapshots.

16 How to find leaked Objects?  More Disciplined approach. Establish a hypothesis (around the expected leak area) (What you expect to see). Design and run an experiment to prove your hypothesis (a use case). Compare the experimental results against your hypothesis. Resolve the differences. (if any)

17 Loitering Objects Recap  Objects that remain within the heap past their useful life to the application.  To eliminate loitering objects from your application, you must first: Identify which objects (if any) are loitering within your application. Determine why those objects remain reachable beyond their designed lifetime.

18 Some Tips  Reference variable scope: Don’t be concerned about assignments to method-based reference variables within methods of short execution time. Be attentive of assignments to class- based and object-based reference variables, and method-based reference variables within methods of long execution time.

19 Some Tips  As a general rule do not use finalizer.  Where appropriate to your design, use the method attributes: static final private

20 Some Tips (Continued)  Try to keep critical methods to a few statements in length, and declare them static, final or private.  In critical loops, avoid method calls within the loop termination test.. Example on next page

21 Some Tips (Continued) Replace … for (int i=0; i < collection.size(); i++){ …. } With for(int i=0, n=collection.size(); i<n; i++) { --- }

22 Some Tips (Continued)  If you cache some objects you better have a “working” caching strategy and remove objects from cache at some point.  No user session really means “0” user session in the system.

23 Questions & Comments “!”