Home

JProbe Tutorials

image

Contents

1. 0 o Anomal evaluat 8 3 E coco 8S RE coco ots coco oS SB Recorded Level Ful Encapsulation Joc Smed Gi Agpepte T crcapcuated 3 Performance Analysis Demos 53 Polynomial Tutorial The method was called only once and took 14 of the cumulative time to execute Tip If the Methods view shows the actual values you can modify it to display percentages by clicking Tools gt Options gt Data Display gt Performance selecting the Show Percentage Time Values in Methods View Trees check box and clicking OK Note This value may vary when running this tutorial on a different platform The actual time is less important than the comparative difference between the two algorithms In the Snapshots Navigator right click the snapshot select Save Snapshot As name the snapshot Polynomial and click Save Close all Performance views Step 4 Running the Polynomial with Improved Code The original algorithm is slower than expected Based on the hypothesis the algorithm that implements Horner s Rule should run faster To use the Horner s Rule algorithm you need a new program argument You can either edit the existing configuration or create a separate configuration to make it easy to switch between tests In this tutorial you create a copy of the existing configuration and edit it To run and assess the Horner s Rule algorithm 1 In the Configurations Navigator right click Polynomial and selec
2. In the Integrate tab use the browse button to navigate to your working directory and click Save to save the startup file Click Next The Run Configuration tab is displayed Select the Close syscon window on exit check box and click Run amp Connect JProbe is searching for currently running engines and JVMs after a few seconds the JProbe Console connects to the JProbe Analysis Engine running the polynomial application using the fixed code The Polynomial program starts and runs in a command window When the program is finished the command window closes JProbe takes a performance snapshot and displays it in the Snapshots Navigator The Summary view is also displayed In the Summary view double click the Polynomial evaluate method suggested for investigation in the Performance Hotspots section The Methods view opens with the selected Polynomial evaluate method as the focus method The method is highlighted in both the graph and the list Performance Analysis Demos 55 Polynomial Tutorial weicome R3 Summary Ea Methods F oso hansome v A EL we gt ee es o J Cal Tree Cat Graph Fiter Methods 8 8 Name Cats CPU Method Ewo Method Y CPUCmi Bap Cmi Avo FU Method a CPU Me Avg Elin Method a Elp Method 3 WE lt tiread gt Omer Threads 5 o sea o Sea o 0 143 3 En read main i a P 7 a o 7 9 E java io PrintStream printgava lang Sring 751 16 16 fa J 1
3. Don t ask me about this again The Performance Difference view appears displaying the differences between the two methods weicome F3 Summary Ra Metnoas R Performance Difference 7 Fiter Methods 09419 Baseline Pulynomal Other Polynomisirined Nate ok ouma pmd crucm esp cri avg Chu methad Avg elp method lt thread gt Other Threads s 0 p 0 A o m theead gt man o o 2 203 185 o 2 denon performance spobynenial Polyresin sv o o o as 187 o o lt rect gt 203 tadi pva lang String equate java lang Object 9 0 o o o o pavato Prinestream pretieg jen lang Str o o s o o o a javalo PrintStream printijawa lang String 16 16 6 1 s A o 54 37 a n7 3 7 o 37 o a7 o cthread gt Finaizer i cthresd gt Attach Listener i J lt tresi gt Sya Ospatcher 4 o cthread gt Reference Hander a 3 a7 37 eeoo 317 The number of calls to Polynomial evaluate did not change but the Elapsed Cumulative Time has decreased by 181 Note Negative values represent a performance improvement Therefore the Horner s Rule algorithm runs considerably faster than the nested loop algorithm Coverage Analysis Demos This chapter provides a summary of the Coverage demo applications that ship with JProbe and a tutorial for one of these applications The source code and compiled classes for the Coverage demos are located in the lt jprobe_home gt
4. E demos performance polynomial Polynomial evatua 1 0 1 2 o 0 o a T java o PrintStream printingava lang S 1 0 0 0 0 o 0 0 E demos performance polynomial Por 1 o o 16 w o o o 0 4 R java tang String equalsGava lang Object 0 o o o o o o o a roor 1 0 0 v xs 0 0 0 0 Recorded Level Ful Encoprdation Joc Mehdi Gi Aggregate T Encagradated The method was called only once and took 5 6 of the cumulative time to execute 12 In the Snapshots Navigator right click the snapshot select Save Snapshot As name the snapshot PolynomialFixed and click Save Step 5 Measuring the Performance Improvement You know that the second algorithm runs much faster than the first one In this step you will quantify the performance improvement using the Snapshot Difference window to compare snapshots To measure the performance improvement 1 Inthe Snapshots Navigator right click the PolynomialFixed snapshot and select Snapshot Differencing The Performance Difference dialog box appears with PolynomialFixed displayed in the Snapshot to Compare list Performance Difference R Select Snapshots Baseline Snapshot e w Snapshot to Compare PolynomialFixed v 2 Select Polynomial from the Baseline Snapshot list and click OK 56 JProbe Tutorials 3 If the following warning dialog appears click Yes Warning p The selected snapshots may not be from the same application The difference results 7 may not be meaningful Continue
5. Object Monitors Locked by Thread demos per formance diners ChopStick 198c6 3 Stack Trace demos per formance diners Philosopher run Philosopher java 86 java lang Thread run Unknown Source lt 46 JProbe Tutorials 3 Investigate all the deadlocked threads by repeating step 2 for each deadlocked thread in the list You can see that Philosopher 1 is waiting for a lock owned by Philosopher 2 who is waiting for a lock owned by Philosopher 3 and so forth This shows that this cycle is causing the deadlock The status area also shows the stack trace for each thread In this case each thread is in the Philosopher run method in Philosopher java Tip If line numbers are not shown you must recompile your program with line information for example javac g If line numbers are still not shown you may need to disable the JVM s JIT Just In Time or optimizing compiler Performance Analysis Demos 47 Polynomial Tutorial Polynomial Tutorial The Polynomial tutorial illustrates how an inefficient algorithm can significantly impact the performance of your code and how you can use JProbe to compare performance and identify the more efficient algorithm Tip You only want to optimize algorithms in the critical path of your program there is no point tuning algorithms that are called very rarely You also need to evaluate the overall impact on the runtime of the program If an inefficient algorithm takes a total of a
6. In Windows lt JPROBE_HOME gt demos settings startWith_MemAnalysis bat In a UNIX or Linux shell lt JPROBE_HOME gt demos settings startWith_MemAnalysis sh The Geronimo Tomcat application server and the Game Pack application start in a command line window and the Welcome to the JProbe Game Pack Demo Application page opens in a Web browser Note If the Web browser does not open the welcome page you can open a browser and type http localhost 8686 gamepack The default value of the pre configured Geronimo HTTP port is 8686 The Game Pack welcome startup page appears Open the JProbe Console and click Attach to Session In the Attach to Session dialog box select the JProbe Analysis Engine and click OK JProbe connects to the Game Pack application and the Runtime Summary view opens in the Console rt the session from the JProbe Console Click the Configurations tab and expand Apache You can see that JProbe includes a pre defined configuration file for the Game Pack memory demos Click Demo Gamepack Memory Analysis The Gamepack_Mem_Settings jpl tab is displayed in the View area Click through the configuration tabs to review the settings Note These pre defined settings cannot be modified or deleted Also you do not need to integrate your application with JProbe because a startup script is already provided for this demo To run the Game Pack startup script and also connect the JProbe Console click Run amp Conne
7. in front of the other J2EEServer statements that is J2EEServer Geronimo and J2EEServer WebLogic10 3 c Save the file Note AJBOSS_HOME environment variable is required for the build to work 2 Atacommand prompt navigate to the lt JPROBE_HOME gt demos gamepack directory and enter the following command Note The Ant deploy ear command given in this procedure deploys on JBoss the Game Pack files provided with JProbe ant f build build xml deploy ear A successful build includes the following types of messages deploy tofolder 102 JProbe Tutorials copy Copying 1 file to lt JBOSS_HOME gt server default deploy echo INFO lt JPROBE_HOME gt demos gamepack support deployment JBossWithTomcat gamepack ear has been deployed to lt JBOSS_HOME gt server default deploy BUILD SUCCESSFUL 3 Start JBoss using the lt JBOSS_HOME gt bin run bat file 4 To view the Game Pack open a browser and enter http localhost lt port gt gamepack where lt port gt is Tomcat s http port number The default value is 8080 The Game Pack startup welcome page appears You can now exercise the tutorials by clicking the available links For more information see Running Game Pack with the JProbe Application on page 109 Building and Deploying Game Pack on JBoss If you want to make any changes in the Game Pack source files then you have to build a new Game Pack EAR file using the updated code and deploy
8. JProbe and contains tutorials for some of these applications The source code and compiled classes for the Memory demos are located in the lt jprobe_home gt demos memory directory This chapter contains the following sections Summary of Demos for Memory Les Erano NWN eenn iste triennial aiaateiein 16 GOGO TNCs aks nines aadneesiis daar d ha otiediaehadaliaa balan adn tbat 28 14 JProbe Tutorials Summary of Demos for Memory The following table describes the purpose of the example applications Java SE Application Account class Purpose This application creates an account object and it is used by the AccountInfo class application More Information See the notes in Account java AccountInfo class Displays three sets of account information to illustrate the impact of indirect object instantiation See the notes in AccountInfo java LeakExample class This example illustrates how an obsolete collection reference may cause loitering objects When the buttons are removed from a panel the JButton objects are not removed from the Java heap See the notes in LeakExample java Tutorial LeakExample Tutorial on page 16 LeakExample2 class Similar to LeakExample class this application registers the buttons as listeners The program demonstrates loitering objects caused by an obsolete listener See the notes in LeakExample2 java Network class This example simula
9. To identify short lived objects 1 Ifthe object_cycling snapshot is not open right click it in the Snapshots Navigator and select Open Instances View The Instances view appears 2 Select Dead Count from the Investigate by list and sort the table by Dead Count You can see that many String and StringBuffer instances are immediately garbage collected that is high Dead Count values and low Recorded Count values 3 Drill into the Merged Allocation Points and Call Traces views by selecting the StringBuffer instance right clicking and selecting the Open Merged Allocation Points View and Open Call Traces View respectively 4 Inthe Merged Allocation Points view right click My Code and select Replace Category with More Detail then sort by Cumulative Count You can see that most of the StringBuffer objects were allocated by renderGameMap_StringConcatenation renderGamePlay_StringConcatenation and renderSnapshot_StringConcatenation methods in the MatchGameRenderer class demos gamepack matchgame package 82 JProbe Tutorials Step 6 Investigating Object Cycling In Java the JVM converts string concatenations into StringBuffer objects which means that each concatenation creates a new object with a very short life span This is a less efficient way to handle strings Take a look at the source code to see exactly how the application works The _StringConcatenation methods are in the MatchGameRenderer java source code Y
10. and navigate to where you want to save the snapshot Name the snapshot minesweeper_methodtime and click Save The new name is displayed in the Snapshots Navigator Click Detach From Session F The Summary view appears after a few seconds Note If a different snapshot is already opened in the JProbe Console the new snapshot taken does not open automatically To open it right click the snapshot name in the Snapshot navigator and select Open Snapshot On the Game Pack demo page click Logout then close the browser Shutting Down the Server In this step you close the Geronimo Tomcat application server To stop the Geronimo Tomcat server 1 2 3 Open a command window and navigate to lt JPROBE_HOME gt demos settings Type in the following command e In Windows startWith_PerfAnalysis bat stop e Ina UNIX or Linux shell startWith_PerfAnalysis sh stop Type in Username system JProbe Game Pack for JavaEE 87 Quick Game Pack Evaluation 4 Type in Password manager The Geronimo Tomcat application server shuts down and the JProbe Execution Console closes Step 5 Identifying the Performance Bottleneck In this step you use the Performance views to identify a hotspot A hotspot is an expensive method one that takes more time than necessary to run The hotspot method may be the performance bottleneck or the method may call another method that causes the slowdown In this example you find two expensive
11. java util ArrayList 0 15 0 360 62 152 42 1 008 a We know that StringBuffer instances may be created when String objects are concatenated and that both of these use char Therefore String and Sim Connection are good candidates for further investigation Step 4 Investigating Large Allocations of Short Lived Objects In this step you investigate the short lived objects identified in Step 3 Identifying Large Allocations of Short Lived Objects by looking at the source code Remember that in this example the code contains the fixed code as well The problem areas are identified in the code comments Note To discover where instances are allocated drill down on an allocation hotspot to display its stack trace in the Merged Allocation Points view You can then look for your allocating method in the stack trace and drill down on it to see the source code To investigate the garbage collected objects 1 Select Sim Connection right click and select Open Merged Allocation Points View 2 Right click My Code and select Replace Category with More Detail The upper pane of the Merged Allocation Points view displays the SimSServer query method which allocates instances of Sim SConnection The Source column indicates the line of code where this method occurs Memory Analysis Demos 33 Network Tutorial Name Cumulative Count Cumulative Memory Source E demos memory sim Sim Server query int java lang String java 80 000 Sim
12. 87 88 89 public void removeButtonFromPanel 90 if numRemoveButtons gt 0 91 panel remove buttons removeButt onIndex numRemoveButtons 92 93 if fixed 94 buttons removeButtonIndex mumRemoveButtons null 95 j 96 97 panel validate 98 panel repaint 99 lt gt Notice that the line of code that removes buttons from the buttons array is encased in an if statement in essence it is missing You have confirmed that the buttons array is the live object that is holding the loiterers in memory Note In Step 5 Running the Memory Leak Session with Improved Code you learn how to remedy this problem by running the code with the ix program argument thus proving that the original hypothesis is correct 8 Close the Source view 9 Optional To find out how much memory is consumed by the loiterer review the Heap Memory column in the Instances view and the Keep Alive Size column in the Instance Detail view Note The sign in the Instances view s Keep Alive Size column indicates an estimated value for this metric To calculate the actual size right click the JBut ton instance and select Calculate Actual Keep Alive Size from the list You may be surprised at how many instances are held in memory by a single JButton instance The Keep Alive Size for a JButton instance is 12 512 Note These numbers may vary depending on which JVM you used to run the Leak Example 10 Close the Instan
13. Apache You can see that JProbe includes a pre defined configuration file for the Game Pack performance demo Click Demo Gamepack Performance Analysis The Gamepack_Perf_Settings jpl tab is displayed in the View area Click through the configuration tabs to review the settings Note These pre defined settings cannot be modified or deleted Also you do not need to integrate your application with JProbe because a startup script is already provided for this demo JProbe Game Pack for JavaEE 85 Quick Game Pack Evaluation 4 Torun the Game Pack startup script and also connect the JProbe Console click Run amp Connect The JProbe Execution Console opens the Geronimo Tomcat application server and the Game Pack application start and the Welcome to the JProbe Game Pack Demo Application page opens in a Web browser Note If the Web browser does not open the welcome page you can open a browser and type http localhost 8686 gamepack The default value of the pre configured Geronimo HTTP port is 8686 The Game Pack welcome startup page appears JProbe connects to the Game Pack application and the Runtime Summary view opens in the Console Step 2 Logging in to Game Pack In this step you log in to the Game Pack demo 1 In the Welcome to the JProbe Game Pack Demo Application page click Start using Game Pack The Game Pack demo login page appears 2 Enter your User ID and Password then click Login Note The first time y
14. Instance Detail view appears listing all the instances of JBut ton in the heap b javax swing JButton Oxicb Memory Analysis Demos 23 LeakExample Tutorial 4 464 13 43 415 4 28 1 040 LeakExample javax swing JButton 0x153 464 13 40 980 4 28 1 040 LeakExample 80 javax swing JButton Ox1e3 464 13 43 744 4 28 1 040 LeakExample 80 javax swing JButton Ox1fb 464 13 44 088 4 28 1 040 LeakExample 80 J javax swing JButton 0x183 464 13 41 619 4 28 1 040 LeakExample 60 i javax swing JButton 0x213 464 13 44 556 4 28 1 040 LeakExample 80 javax swing JButton 0x277 464 13 45 494 4 28 1 040 LeakExample 80 javax swing JButton 0x19b 464 13 42 025 4 28 1 040 LeakExample 80 javax swing JButton 0x22b 464 13 45 009 4 28 1 040 LeakExample 60 javax swing JButton 0x300d 464 5 32 1 056 Trace was not collected Referrers References Dominators Trace F Referrers References Name A Type Keep Alive Size FieldName Field Name 4 Type Keep Alive Size Name java beans PropertyChangeSuppo FIELD 232 source lt class javax swing JBu CLASS 2672 lt class gt javax swing JBu E java beans ProperyChangeSuppo FIELD 56 source E aaTextinfo FIELD 24 sun swing SwingUtilties2 _ javax swing AbstractButton Handl FIELD 16 this 0 E actionListener FIELD 16 javax swing AbstractButt amp javax swing JButton Oxtaef ARRAY 11136 javax swin E amp actionMap FIELD 16 javax
15. JProbe Analysis Engine running the polynomial application 52 JProbe Tutorials Step The Polynomial program starts and runs in a command window When the program is finished the command window closes JProbe takes a performance snapshot and displays it in the Snapshots Navigator The Summary view is also displayed Note If a different snapshot is already opened in the JProbe Console the new snapshot taken does not open automatically To open it right click the snapshot name in the Snapshot navigator and select Open Snapshot 3 Identifying and Investigating the Performance Bottleneck By default the snapshot taken at the end of the session is displayed in the Snapshot Navig ator The Summary view presents a list of performance hotspots and guides you on how to investigate any performance hotspots To investigate performance bottleneck in your application 1 In the Summary view double click the evaluate method suggested for investigation in the Performance Hotspots section The Methods view opens with the selected Polynomial evaluate method as the focus method The method is highlighted in both the graph and the list welcome E3 Summary Methods SS Color to Show Mot Methods Elapsed Time ie we G sf g bo E man a gt o A ee eee J Cal Tree cat aaoh is Cats CPUMeR Ep Method Y CPU Cmi Elap Cmi Avg CPU oU Avg Elp Me o Elp Method s 0 1 328 o RI o
16. Logic 28 6 ME 28 3 E 100 0 RoomList 20 0 W 26 1 W 100 0 Kitchen 0 0 0 0 100 0 Room 0 0 0 0 100 0 Bathroom 0 0 0 0 100 0 Show Only Methods with Missed Li Y gt Method Missed Lines Missed Lines Total Lines demos coverage adventure Adventure lt init gt Yes 100 0 demos coverage adventure Adventure main java lang String J No 50 0 E Fe demos coverage adventure Adventure cleanup Yes 100 0 M 6 6 demos coverage adventure Adventure printUsage Yes 100 0 ME 2 2 demos coverage adventure Adventure initializeRoomList No 25 0 W 2 8 demos coverage adventure Adventure play No 50 0 W f 2 demos coverage adventure Adventure lt init gt java lang String No 0 0 0 9 4 Select the main method right click and select Show Source to open the lt jprobe_home gt demos coverage adventure Adventure java source code The source code opens at a block of missed lines that are in an if statement so you know that the test case missed a condition You have identified an opportunity to expand the test suite with a new test case In this case you would pass two input files as program arguments 5 Click the Down 7 button at the top of the coverage bar to the right of the scroll bar to move to the next set of missed lines We can see that code is missed because input is not coming from the console You can ignore these misses 6 Continue in this way until
17. Quest Central Quest vToolkit Quest vWorkSpace ReportADmin RestoreADmin SelfServiceADmin SharePlex Sitraka SmartAlarm Spotlight SQL LiteSpeed SQL Navigator SQL Watch SQLab Stat StealthCollect Storage Horizon Tag and Follow Toad T O A D Toad World vAutomator vControl vConverter vFoglight vOptimizer Pro vPackager vRanger vRanger Pro vSpotlight vStream vToad Vintela Virtual DBA VizionCore Vizioncore vAutomation Suite Vizioncore vBackup Vizioncore vEssentials Vizioncore vMigrator Vizioncore vReplicator Vizioncore vTraffic Vizioncore vWorkflow WebDefender Webthority Xaffire and XRT are trademarks and registered trademarks of Quest Software Inc in the United States of America and other countries Other trademarks and registered trademarks used in this guide are property of their respective owners Disclaimer The information in this document is provided in connection with Quest products No license express or implied by estoppel or otherwise to any intellectual property right is granted by this document or in connection with the sale of Quest products EXCEPT AS SET FORTH IN QUEST S TERMS AND CONDITIONS AS SPECIFIED IN THE LICENSE AGREEMENT FOR THIS PRODUCT QUEST ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTY OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE OR NON INFRINGEMENT IN NO EVENT S
18. Shutting Down the Server e Step 5 Identifying the Performance Bottleneck e Step 6 Running the Session with Improved Code 84 JProbe Tutorials Step 1 Step 7 Measuring the Performance Improvement Starting the Session and the Game Pack In this step you start the Geronimo Tomcat server using the pre defined startup script shipped with JProbe then connect JProbe to the Game Pack application running on this server To start the session from command line 1 Type in the following command depending on your platform In Windows lt JPROBE_HOME gt demos settings startWith_PerfAnalysis bat In a UNIX or Linux shell lt JPROBE_HOME gt demos settings startWith_PerfAnalysis sh The Geronimo Tomcat application server and the Game Pack application start in a command line window and the Welcome to the JProbe Game Pack Demo Application page opens in a Web browser Note If the Web browser does not open the welcome page you can open a browser and type Attp localhost 8686 gamepack The default value of the pre configured Geronimo HTTP port is 8686 The Game Pack welcome startup page appears Open the JProbe Console and click Attach to Session In the Attach to Session dialog box select the JProbe Analysis Engine and click OK JProbe connects to the Game Pack application and the Runtime Summary view opens in the Console To start the session from the JProbe Console 1 Click the Configurations tab and expand
19. appears informing you that JProbe detected a deadlock and has reduced the threads list to the threads involved in the deadlock Click OK The thread list updates to show only the deadlocked threads which in this case are only the Philosopher threads Step 3 Investigating the Deadlock As presented in Step 2 Running the Diner Session the JProbe Execution Console reported deadlocks among the Philosopher threads To see where each thread is deadlocked 1 Inthe Runtime Summary view click the Threads tab if not already selected 2 Select a thread from the thread list and click Update Thread Details The status area is updated with information regarding the selected thread It shows that the thread is blocked on one of the chopstick objects and that it is currently owned by another Philosopher welcome AF Runtime Summary E mD p TkwseTwh ea a Pools and GC Intervali One Hour Classes Loaded 2007 Classes Unloaded 0 Memory Pools GC Data Threads fl Thread States click on a bar to show threads in that state Number of Threads Runnable waiting iblocked Hother o 1 2 3 4 5 6 7 8 Total Threads 19 Last Updated 15 44 49 Filter Threads 5 19 Show all Update Thread Details Philosopher 1 Name Philosopher 1 A Philosopher 2 State BLOCKED on demos per formance diners ChopStick 497062 Philosopher 3 Total blocked 28 Total waited 35 Philosopher 4 Philosopher 5 Lock Owner Philosopher 2
20. few seconds to execute you may make it run faster but the impact on the overall runtime of the program will be negligible The program runs two algorithms for computing the following polynomial expression n 2 ayy OK Et eee Pag FX a a X a where n 750 The original algorithm uses nested loops to calculate x The improved algorithm implements Horner s Rule for evaluating polynomial expressions that is it factors out powers of x in the form an X ayy X a2 X ay AQ Note The values cited in this tutorial reflect the Polynomial running on Windows XP with Sun delivered with JProbe You may see different values on your system but the performance improvement between the algorithms should still be evident The following table summarizes the types of information you need to know before starting this tutorial Program Polynomial class Use Case Calculate a polynomial expression Architecture Both polynomial calculations are in the evaluate method To run the program you need to set a program argument e N Use nested loops original algorithm e H Use Horner s Rule alternate algorithm Hypothesis Horner s Rule is faster 48 JProbe Tutorials The tutorial walks you through the following steps Step 1 Setting Up the Polynomial Session Step 2 Running the Polynomial Session Step 3 Identifying and Investigating the Performance Bottleneck Step 4 Running the Polynomial w
21. files for the tutorial are available in the lt jprobe_home gt demos coverage adventure directory This tutorial does not create a baseline snapshot of the Adventure program because the test cases hit methods in all classes For more information about the baseline coverage snapshot see the JProbe User Guide Note The values cited in this tutorial reflect the Adventure program running on Windows XP with Sun JDK delivered with JProbe You may see different values on your system The following table summarizes the types of information you need to know before starting this tutorial Program Adventure class Test Case AdvTest1 txt AdvTest2 txt The tutorial leads you through the following steps e Step 1 Setting Your Global Options e Step 2 Setting Up the Session for the First Test Case e Step 3 Running the First Test Case e Step 4 Setting Up and Running the Second Test Case e Step 5 Merging the Test Case Results e Step 6 Assessing Your Test Case Coverage Step 1 Setting Your Global Options Catch blocks are often hard to test For this tutorial we are going to remove the results for catch blocks by setting a global option To set global options for the Coverage analysis tool 1 Inthe JProbe Console click Tools gt Options iy on the toolbar 60 JProbe Tutorials 2 Click Data Display gt Coverage 3 Select the Filter out Catch Blocks check box General CSV Export Data Display Memory Perfo
22. held by an obsolete container reference To look for a solution you open the Source view and review the code for the allocating method To investigate loitering objects 1 Ifthe snapshot is not open right click it in the snapshot navigator and select the Open Instances View The Instances view appears 2 Select Heap Count from the Investigate by list 3 Filter the method list by typing GameHandler in the Filter Classes field and pressing Enter 4 Select the GameHand1ler class and click Instance Detail 5 The Instance Detail view opens The three loitering GameHandler objects are displayed in the instances list You can see the stack trace of method calls in the Allocated At column 5 Click the Trace tab and scroll down the method list to the methods belonging to the subpackages of the demos gamepack web game package and find a method called EJBControllerImpl startGame The startGame method calls the getGameHandlerRemote method which in turn sets off a series of calls to JBoss methods that eventually causes the bean to be created Therefore the getGameHandlerRemote method is the most likely candidate for investigation because it is the last Game Pack method before the series of application server calls 6 Select the demos gamepack web game EJBControlleriImpl1 getGameHandlerRemo te method right click and select Show Allocated At Source 7 If you are prompted for the source code navigate to lt jprobe_hom
23. notice any errors in the documentation Were any features undocumented Do you have any suggestions on how we can improve the documentation All comments are welcome Please submit your feedback to the following email address am docfeedback quest com Please do not submit Technical Support related issues to this email address Text Conventions The following table summarizes how text styles are used in this guide Convention Code Description Monospace text represents code code objects and command line input This includes e Java language source code and examples of file contents e Classes objects methods properties constants and events e HTML documents tags and attributes Variables Monospace plus italic text represents variable code or command line objects that are replaced by an actual value or parameter Interface Bold text is used for interface options that you select such as menu items as well as keyboard commands Files components and documents Italic text is used to highlight the following items e Pathnames file names and programs e The names of other documents referenced in this guide About Quest Software Inc Now more than ever organizations need to work smart and improve efficiency Quest Software creates and supports smart systems management products helping our Introduction to This Guide 11 About Quest Software Inc customers solve everyday IT challenge
24. on Your Application Server on page 95 e Running Game Pack with the JProbe Application on page 109 e Game Pack Memory Analysis Tutorials on page 110 e Game Pack Performance Analysis Tutorial on page 122 e Game Pack Coverage Analysis Tutorial on page 128 Deploying the Game Pack Demo on Your Application Server This section presents how to deploy the Game Pack demo on the following application servers e Deploying the Game Pack Demo on Apache Geronimo on page 95 e Deploying the Game Pack Demo on JBoss on page 101 e Deploying the Game Pack on BEA WebLogic Server 10 3 on page 103 e Deploying the Game Pack on Oracle WebLogic Server 11g on page 106 Deploying the Game Pack Demo on Apache Geronimo The process of deploying the Game Pack demo on an Apache Geronimo application server using the Gamepack ear file for Geronimo provided with Game Pack consists of the following main steps 1 Creating a Database for the Game Pack Demo 2 Deploying Game Pack on Geronimo Using the Provided EAR File 96 JProbe Tutorials If you want to make any changes in the Game Pack source files then you have to build a new Game Pack EAR file using the updated code and deploy the new EAR file instead The process of deploying the Game Pack demo on an Apache Geronimo application server using a customized EAR file consists of the following main steps 1 Creating a Database for the Game Pack Demo 2 Building
25. provides information about what is contained in the JProbe Tutorials It also provides information about the JProbe documentation suite and Quest Software This chapter contains the following sections POU POE ise ects o Kk Sek ABbRK ALAR ASNEA SHR E Eanes aN 8 About This GUIdC ccccecesessssessssesessssesssuesssnsssseesssesssnsssessucsusesnsssesesesusnesssceaseseseaescansasesesseuseeneases 8 JProbe Documentation Suite 2 050 iscs ssidd arcs aniis nnair Sanh anda ninhnind ane iwdedts 9 Te Govern oes ac E ca snd a edie Ane ein About Quest Software Inc 8 JProbe Tutorials About JProbe JProbe is an enterprise class Java profiler that provides intelligent diagnostics on memory usage performance and test coverage It allows developers to quickly pinpoint and repair the root cause of application code performance and stability problems that obstruct component and integration integrity JProbe provides three types of analysis e Memory analysis allows a developer to identify and resolve Java memory leaks and object cycling to ensure optimal program efficiency and stability e Performance analysis allows a developer to identify and resolve Java bottlenecks and deadlocks to ensure optimal program performance and scalability e Coverage analysis allows a developer to identify un executed lines of code during unit testing to ensure test coverage and program correctness JProbe also offers an Eclipse plugin that provides
26. ready to investigate your results By default JProbe displays results in terms of misses A miss means that the code was not called during your test cases To investigate your results 1 In the Snapshot Browser view expand the class tree in the upper pane to show all of the classes in demos coverage adventure 2 Click the Missed Methods column heading in the upper pane to sort the table from highest to lowest percentage of missed methods Methods are missed in three classes Adventure Logic and RoomList We will investigate the first two classes Name Missed Classes Missed Methods Missed Lines With Line Data S m o amp demos coverage adventure 0 0 19 4 E 26 1 i 100 0 Adventure 42 9 M 53 1 M 100 0 Logic 28 6 M 28 3 M 100 0 RoomList 20 0 W 26 1 100 0 Kitchen 0 0 0 0 100 0 Room 0 0 0 0 100 0 Bathroom 0 0 0 0 100 0 By default the Adventure program is selected in the top pane which means that the lower pane contains all the methods in the program 3 In the upper pane select the Adventure class Coverage Analysis Demos 65 Adventure Tutorial The methods for the Adventure class are displayed in the lower pane Welcome 9 Coverage Session Snapshot Browser Name Missed Classes Missed Methods Missed Lines With Line Data Adventure 0 0 19 4 26 1 M 100 0 E demos coverage adventure 0 0 19 4 B 26 1 M 100 0 ture
27. server lib api jar lt WLS_HOME gt modules javax persistence_1 0 0 0_1 0 2 jar b Delete the pound sign from the J2EEServer WebLogic10 3 statement c Add a pound sign in front of the other J2EEServer statements that is J2EEServer Geronimo and J2EEServer JBossWithTomcat d Save the file 2 Atacommand prompt navigate to the lt JPROBE_HOME gt demos gamepack directory and enter the following command ant f build build xml deploy The Gamepack ear file is created in the lt JPROBE_HOME gt demos gamepack dist directory Note WebLogic does not automatically deploy the new Gamepack ear file You must manually deploy it using the Weblogic Administration Console 3 Use the WebLogic Administration Console to deploy the Gamepack ear in the lt JPROBE_HOME gt demos gamepack dist directory Running Game Pack with the JProbe Application Follow a tutorial that matches the JProbe application you are using You can open the tutorials from the Game Pack demo by clicking the Tutorials link To run Game Pack with JProbe you must complete the following generic tasks 1 Integrate the JProbe application with your application server Set up your JProbe session Run the JProbe session to start the application server gt wo N Connect the JProbe Console to the session 110 JProbe Tutorials 5 When the application server is started open a browser and go to For Geronimo hittp Nocalhost 8080 game
28. statements that is J2EEServer Geronimo and J2EEServer JBossWithTomcat d Save the file 2 Atacommand prompt navigate to the lt JPROBE_HOME gt demos gamepack directory and enter the following command ant f build build xml deploy The Gamepack ear file is created in the lt JPROBE_HOME gt demos gamepack dist directory Note WebLogic does not automatically deploy the new Gamepack ear file You must manually deploy it using the Weblogic Administration Console 3 Use the WebLogic Administration Console to deploy the Gamepack ear in the lt JPROBE_HOME gt demos gamepack dist directory Deploying the Game Pack on Oracle WebLogic Server 11g For instructions on how to deploy the Game Pack demo on an Oracle WebLogic Server 11g application server using the Gamepack ear file for this server provided with Game Pack see section Deploying Game Pack on Oracle WebLogic Server 11g Using the Provided WebLogic Template JAR File If you want to make any changes in the Game Pack source files then you have to build a new Game Pack EAR file using the updated code and deploy the new EAR file instead For instructions on how to deploy the Game Pack demo on a Oracle WebLogic Server 11g application server using a customized EAR file see section Building and Deploying Game Pack on Oracle WebLogic Server 11g JProbe Game Pack for JavaEE 107 Advanced Game Pack Evaluation Deploying Game Pack on Oracle WebLogic Server 11g Using the
29. swing ActionMap 0 E appContext FIELD 2480 sun awt AppContext Ox background FIELD 40 javax swing plaf ColorUI E border FIELD 32 javax swing plaf Border E changeListener FIELD 16 javax swing AbstractButt J Al i a ce m a Sb Root E Static Root A Recorded Not Recorded GB cycle Tip The view displays 12 JButtons not 10 The other two buttons were not added while the recording was ON hence the recorded count in the Instances view is 10 and the heap count is 12 2 In the upper table click the first instance with an allocation time displayed then click Leak Doctor eg on the toolbar The Leak Doctor view appears Instance javax swing JButton 0x103 W welcome GF Runtime Summary B instances Pal Instance Detail W Leak Doctor Field Name Keep alive Size 7 EOS F Root javax swing JButton 0x1aef Recording Boundary ARRAY javax swing JButton 3 11 136 javax swing AbstractButton Handler Oxi bb FIELD this 0 16 java beans PropertyChangeSupport Ox1be FIELD source 232 java beans PropertyChangeSupport Ox1c6 FIELD source 56 Name Comment Type Field Name Keep Alive Size Static Root amp Recording Boundary A Cycle 24 JProbe Tutorials 3 Select the first instance and click Remove The Edge ts on the toolbar A dialog box confirms that this instance is eligible to be garba
30. tab The Summary tab is displayed It presents a summary of the settings defined for your configuration To create a JPL file and a startup script click Save amp Integrate Click Save to save the configuration file CoverageLoitering_Cov_Settings jpl into your working directory Tip Itis a good practice to save the configuration files into a directory other than the JProbe installation directory for example C JProbeFiles The Integration Wizard dialog box appears displaying the integration status In the Integrate tab click the browse button and navigate to the location where you want to save the startup script for example in Windows run_WithJProbe bat and in UNIX Linux systems run_WithJProbe sh then click Save Tip Itis a good practice to save the script files into a directory which is recommended by the integration Status dialog for example in this case the recommended path is C lt jboss_home gt bin directory When the integration is complete click Next The Run Configuration tab is displayed JProbe Game Pack for JavaEE 131 Advanced Game Pack Evaluation 15 Select the Close syscon window on exit check box to automatically close the Jpsyscon window after the termination of the launched script if the program exits normally 16 To run your application with JProbe using the startup script click Run amp Connect Note To start JBoss using the startup script In Windows C lt jboss_home gt
31. the new EAR file instead To correctly build the Game Pack code with latest EJB 3 0 specification dependency libraries for JEE server the classpath J2EEServer property must contain paths to the following JAR files existing in the JBoss installation directory e jboss javaee jar e ejb3 persistence jar Alternatively you can copy the JBOSS Java EE 5 libraries jboss javaee jar and ejb3 persistence jar in lt JBPROBE_HOME gt gamepack ib directory no property setting is required in this case To build and deploy the Game Pack demo on JBoss 1 In the lt JPROBE_HOME gt demos gamepack build directory edit the build properties file a Update classpath J2EEServer property with the paths to the following files lt JBOSS_HOME gt client jboss javaee jar lt JBOSS_HOME gt client ejb3 persistence jar JProbe Game Pack for JavaEE 103 Advanced Game Pack Evaluation b Delete the pound sign from the J2EEServer JBossWithTomcat statement c Add a pound sign in front of the other J2EEServer statements that is J2EEServer Geronimo and J2EEServer WebLogic10 3 d Save the file 2 Atacommand prompt navigate to the lt JPROBE_HOME gt demos gamepack directory and enter the following command ant f build build xml deploy The Gamepack ear file is created in the lt JPROBE_HOME gt demos gamepack dist directory and the new Game Pack build is deployed on the JBoss application server A succe
32. window click Start and let the program run until a deadlock occurs The program stops when a deadlock occurs because each philosopher has only one chopstick Tip If a deadlock does not occur at all click Stop adjust the slider to a lower value to change the timing then click Start to rerun the program Repeat until a deadlock occurs 2 Inthe JProbe Console on the Runtime Summary view click the Threads tab The chart in the upper pane shows that at least five threads are blocked The thread list in the lower pane shows the current threads in the program Wwelcome F Runtime Summary gt A E ea a Pools and GC Interval One Hour Classes Loaded 2007 Classes Unloaded 0 Memory Pools GC Data Threads Thread States click on a bar to show threads in that state Number of Threads Runnable Waiting Bislocked Hother L 0 1 2 3 4 5 6 7 8 Total Threads 19 Last Updated 15 39 01 Filter Threads 19719 Show All jate T Detect Deadlock Philosopher 1 Philosopher 2 Philosopher 3 Philosopher 4 Philosopher 5 3g Java RMI Threads 3a Java UI Threads Erd Java VM Threads Z IMX Threads Performance Analysis Demos 45 Philosopher s Diner Tutorial 3 Click Detect Deadlock If no deadlock has occurred the No Deadlock Detected dialog appears informing you that JProbe did not detect any deadlocks If a deadlock has occurred the Deadlock Detected dialog
33. 0 ME 6 6 demos coverage adventure RoomList lt init gt java lang String Yes 100 0 ME 6 6 demos coverage adventure Logic changeRoom No 36 4 E 4 11 demos coverage adventure Logic execute No 28 6 E 4 14 demos coverage adventure Logic getDirectionChoice Yes 100 0 M 3 3 demos coverage adventure Adventure initializeRoomList No 25 0 W 2 8 demos coverage adventure Adventure printUsage Yes 100 0 ME 2 2 demos coverage adventure Adventure play No 50 0 B f 2 demos coverage adventure Adventure lt init gt java lang String No 0 0 0 9 demos coverage adventure Bathroom lt init gt No 0 0 o 7 demos coverage adventure Logic lt init gt demos coverage adventure RoomlList jav No 0 0 o demos coverage adventure Logic checkAndChangeDirection No 0 0 0 z demos coverage adventure Logic cleanup No 0 0 0 4 oO demos coverage adventure Room lt init gt No 0 0 o 2 demos coverage adventure Room lt init gt demos coverage adventure RoomList No 0 0 o 12 demos coverage adventure Room checkSelection java lang String No 0 0 o 5 demos coverage adventure Room setAssociatedNames int J No 0 0 o 4 demos coverage adventure Room setDescription java lang String No 0 0 o 2 demos coveraqe adventure Room setDirections iava lana Strina T No 0 0 o 4 62 JProbe Tutorials Step 4 Setting Up and Running the Second Test Case To run JProbe with a different test case you need to change the program argu
34. 00 03 00 00 03 30 00 04 00 00 04 30 00 05 00 00 05 30 00 06 00 00 06 30 00 07 00 2 Inthe Instances view select Dead Count from the Investigate by list 3 Click the Dead Count column header twice to sort the table by the classes with the most garbage collected instances The top classes by Dead Count can vary by JVM and platform but typically include char String StringBuffer and Sim Connection Few or none of the recorded instances of these classes remain at the end of the session 32 JProbe Tutorials Filter Classes x 538 538 Name Recorded Count Heap Count Recorded Memory Heap Memory Keep Alive Size Dead C Y Dead Memory Total 5 059 17 243 107 680 1 066 040 1 066 040 63 978 3 488 792 char 2 2 691 128 169 928 169 928 30 110 2 807 624 A 10 060 F java lang StringBuffer 0 4 0 64 384 10 007 160 112 java awt Dimension o o o 0 o 5 265 84 240 demos memory sim Sim Connection 0 0 0 0 o 5 000 80 000 sun java2d d3d D3D5urfaceData D3DWindo 0 0 0 0 0 1 514 30 280 java awt Rectangle o 0 0 o 0 750 18 000 java util concurrent lacks AbstractQueuedSy 0 6 o 192 192 337 10 784 java lang Object 4 338 25 664 40 824 123 320 179 28 752 java lang management MemoryUsage 0 0 o o 0 105 4 200 java lang ref WeakReference 2 36 48 864 864 101 2 424 sun awt EventQueueltem 0 0 0 0 0 98 1 568 java awt EventQueueltem 0 o 0 o 0 88 2 112 java awt event MouseEvent 0 0 0 0 0 44 3 168
35. 1 in the Configurations Navigator The Configuration Details tab is displayed in the View area 3 Click Edit 4 Inthe Configuration Name text box type NetworkFixed as the name for the new configuration 5 Click the Java Application tab to change the program argument a Click the browse button beside the Application Arguments field In the upper field of the Application Arguments dialog box type fl fe 10 11 Memory Analysis Demos 35 Network Tutorial b Click Parse Arguments The arguments appear in separate lines in the lower list c Click OK The Application Arguments field displays the program arguments Click Save then click Save As to save the configuration file NetworkFixed_Mem_Settings jpl into your working directory Tip Itis a good practice to save the configuration files into a directory other than the JProbe installation directory for example C JProbeFiles Click Integrate The Integration Wizard appears JProbe validates the configuration file and creates a startup script file for example in Windows NetworkFixed bat and in UNIX Linux systems NetworkFixed sh Tip Itis a good practice to save the script files into a directory other than the JProbe installation directory for example C JProbeFiles In the Integrate tab use the browse button to navigate to your working directory and click Save to save the startup file Click Next The Run Configuration tab is displayed Select the Close sys
36. 360 java util concurrent locks AbstractQueuedSy o 5 o 160 160 329 10 528 java lang ref WeakReference 1 36 24 864 864 316 7 584 java awt EventQueueltem 0 0 o 0 0 310 7 440 java awt event MouseEvent 0 0 0 0 0 133 9 576 java awt event InvocationEvent 0 0 0 0 0 128 7 168 java util HashMap Entry 0 628 a 15 072 23 544 126 3 024 sun java2d pipe Region 1 3 32 96 96 116 3 712 java awt Point 0 0 0 0 0 116 1 856 char 2 2 688 128 169 824 169 824 108 7 104 java awt Event 0 0 0 0 0 87 5 568 java awt event PaintEvent 0 0 0 0 0 69 2 208 java awt geom AffineTransform i 12 64 768 768 65 4 160 sun java2d SunGraphics2D i 200 200 264 65 13 000 java lang management MemoryUsage o o 0 o 65 2 600 sun awt Repaintarea 0 o 64 160 49 784 java awt Rectangle 0 o 96 96 49 1 176 java lang String byte 2 27 32 27 504 27 504 32 3166 The Dead Count of String now reports 39 instances down from more than 10 000 instances in the original example The total number of Dead instances has also decreased from 33 000 in original example to 8 420 in the fixed code You will notice the following e The String count is much lower 39 e The Sim Connection count is even lower 5 e java awt Dimension now has the highest dead count Memory Analysis Demos 37 Network Tutorial 14 To investigate java awt Dimension select it right click and select Open Merged Allocation Points View 15 In the upper pane of the Merged Allocation Points view right click Sytem
37. 4 640 11 5 104 You can see that in the new snapshot obtained by running with the fix argument there are ten fewer JButton objects than in the original snapshot The Recorded Count and Heap Count are 10 and the Heap Memory is reduced by approximately 4 640 bytes Therefore removing the JButtons from the JButton array fixed the problem In the upper side of the view you can also see that the LeakExample code now uses memory more efficiently The improved code reduced the Recorded Memory use by 89 15 28 JProbe Tutorials Network Tutorial The Network program illustrates how over allocating short lived objects can cause the garbage collector to run longer than necessary Garbage collection takes time and resources This tutorial demonstrates how to use JProbe to identify excessive garbage collections in your code The fixed code shows that it is often more efficient to reuse objects or cache data Note The values cited in this tutorial reflect the Network example running on Windows XP with Sun JDK delivered with JProbe You may see different values on your system but the improvement in garbage collection overhead should still be evident The following table summarizes the types of information you need to know before starting this tutorial Program Network class Use Case Connect from a client to a server query a database and return a result to the client Architecture See the comments in the Network java sourc
38. Close Wizard Cancel Help 20 When the integration is complete click Next The Run Configuration tab is displayed 21 Select the Close syscon window on exit check box to automatically close the jpsyscon window after the termination of the launched script if the program exits normally 22 To run your application with JProbe using the startup script click Run 20 JProbe Tutorials Step 2 Running the Memory Leak Session In this step you exercise a use case on LeakExample that requires you to add buttons to a panel and then remove them As the use case runs you can see how many JButton objects have been added since the exercise started and how many remain in the heap when it ends Note This procedure assumes that the LeakExample program is already running for instructions on how to execute the startup script see step 22 in section Step 1 Setting Up the Memory Leak Session on page 17 Alternatively you can run the startup script from the command line In a Windows command window LeakExample bat In a UNIX or Linux shell from the directory where you saved the startup script LeakExample sh To run the session Click Attach to Session i on the JProbe Console toolbar JProbe is searching for currently running engines and JVMs and displays this list in the Attach to Running Session dialog box Select from the list the JProbe Analysis Engine running with the application and click O
39. Code end select Expand To Next Branch Point 16 Right click My Code and select Replace Category With More Detail 17 Select the method with the large number of instances 3 345 right click and select Show Allocated At Source Line Source o Do not cache window may resize 226 int width d width 227 int height d height 228 gr setColor server_db state Color red Color white 229 gr drawbine int server_db_connection 0 width 230 int server_db_connection 1 height 231 int server_db_connection Z width 232 int server_db_connection 3 height 233 gr drawbine int server_db_comnection 0 width 1 234 int server_db connection 1 height 235 int server_db_connection 2 width 1 236 int server_db_connection 3 height 237 for int i 0 i lt 5 itt 238 gr setColor client_server_states i Color red Color white 239 gr drawbine int client _server_connections i 0 width 240 int client_server_connections i 1 height 1 y 241 int iclient_server_connections i 2 width 242 int client_server_connections i 3 height 243 v sji gt You can see that the instances are the result of a get Size call on the main Network Simulation window Because it can be resized the dimensions should not be cached 38 JProbe Tutorials Performance Analysis Demos This chapter provides a summary of the Performance demo applications that ship wi
40. E 11 Quest COMMUNIC sssini ga ia SE EEA TENAS 12 Memory Analysis DeMmos ssssssssssssssscessesssessssscesesesscessesssnsseeseseesesteseeseaceaseseateaeeseaeeaeeseaeeateneaesateeeseaneaeeseneaes 13 Summary of Demos for Memory ssssssesesessssssssssssssssrtrttttteteeeeesssssssssnttrnttttttttttettntntnttntttttrttttttetetntntastitrnrnnttetttett 14 LeakExample Tutorial acces casa i eae a a a ran ach es 16 Step 1 Setting Up the Memory Leak SeSSION 00 ceseessesessecseecsessesestecneesneestecneesteeseesneessesseesueensesatentesneentensenee 17 Step 2 Running the Memory Leak Session cessesseseseesecseesseseesseessesnseneesneessesseesueeseesseesneessesateseesneeseeneses 20 Step 3 Identifying Loitering Objects 0 eseessseseseesecstecseeseeseesseestecseecueesneessecseeatecseesneeseecseeateeseeseeseesneesseesenee 21 Step 4 Investigating Loitering Objects c cccsecsessessesstesesssssessesseenesseesessessesaessessnsesssessussussuseuseessnseessesseseeseeeeess 22 Step 5 Running the Memory Leak Session with Improved Code seessssssssseseseeseseesneessesneeseestesneeseenenns 26 Network Tutorials iiaa a tied A Aaa a a aE dasa a G 28 Step 1 Setting Up the Network Sessions ranne a 29 Step 2 Running the Network SeSSION ssessssssssesssssscsesssssessessessessessessessecanesessussusessssseuseessseeussassnsenseesenseseeeteess 30 Step 3 Identifying Large Allocations of Short Lived Objects cesescesesseseseesesees
41. E QUEST SOFTWARE JProbe 8 3 Tutorials 2009 Quest Software Inc ALL RIGHTS RESERVED This guide contains proprietary information protected by copyright The software described in this guide is furnished under a software license or nondisclosure agreement This software may be used or copied only in accordance with the terms of the applicable agreement No part of this guide may be reproduced or transmitted in any form or by any means electronic or mechanical including photocopying and recording for any purpose other than the purchaser s personal use without the written permission of Quest Software Inc If you have any questions regarding your potential use of this material contact Quest Software World Headquarters LEGAL Dept 5 Polaris Way Aliso Viejo CA 92656 www quest com email legal quest com Refer to our Web site for regional and international office information JProbe Patents Patent pending Trademarks Quest Quest Software the Quest Software logo AccessManager ActiveRoles Aelita Akonix AppAssure Benchmark Factory Big Brother BusinessInsight ChangeAuditor ChangeManager DeployDirector DirectoryAnalyzer DirectoryTroubleshooter DS Analyzer DS Expert ERDisk Foglight GPOADmin Imceda IntelliProfile InTrust Invirtus Token I Watch JClass Jint JProbe LeccoTech LiteSpeed LiveReorg LogADmin MessageStats Monosphere NBSpool NetBase NetControl Npulse NetPro PassGo PerformaSure
42. EAR file instead For instructions on how to deploy the Game Pack demo on a BEA WebLogic Server 10 3 application server using a customized EAR file see section Building and Deploying Game Pack on BEA WebLogic Server 10 3 Deploying Game Pack on BEA WebLogic Server 10 3 Using the Provided WebLogic Template JAR File To deploy the JProbe Game Pack on BEA WebLogic Server 10 3 you use the WebLogic Configuration Wizard The following procedure assumes that you have successfully installed and configured BEA WebLogic Server 10 3 and JProbe v 8 3 To deploy the Game Pack demo on BEA WebLogic Server 10 3 1 Start the WebLogic Configuration Wizard e On Windows click Start gt Programs gt BEA Products gt Tools gt Configuration Wizard e On UNIX systems execute java jar configwiz jar in the WL_HOME wlserver_10 3 common lib directory 2 Select the Create a new WebLogic domain check box and click Next 3 Select the Base this domain on an existing template check box 4 Click Browse and navigate to lt JPROBE_HOME gt demos gamepack support deployment Weblogic10 3 templates domains directory select gamepack jar and click OK 5 Click Next 6 Configure the User name and User password and click Next default is recommended 7 Specify the server start mode by selecting the Development Mode check box 8 Select a JDK from the available list default is recommended then click Next 9 To use the default configuration recommended se
43. For the Game Pack demo we decided to use a different way to build the game board one that does not require that the images be loaded and encoded on the server side Instead the game board is simply a table of HTML links If image caching is enabled in the browser the 88 JProbe Tutorials images are stored and used locally otherwise the links point to images on the Web server To run the session with improved code 1 Repeat Step 1 Starting the Session and the Game Pack to Step 4 Shutting Down the Server selecting Normal mode instead of the Method Time option and save the snapshot as minesweeper_normal 2 Right click minesweeper_normal and select the Open Snapshot The Summary view appears 3 Select the top method suggested for investigation demos gamepack minesweeper MineSweeperRenderer renderMineMa piImage_Norma1 in the Performance Hotspot section right click and select Investigate The Methods view appears 4 In the Call Graph hover over the renderMineMapImage_Normal node to display its tooltip You can see that the Elapsed Method Time is 23 ms and it is called 5 times The new method renderMineMapImage_Normal runs faster than the original renderMineMapImage_MethodTime method Also the new method does not require the encoding servlet so overall the program is even faster Step 7 Measuring the Performance Improvement You know that the image caching algorithm runs much faster than the original compression algo
44. HALL QUEST BE LIABLE FOR ANY DIRECT INDIRECT CONSEQUENTIAL PUNITIVE SPECIAL OR INCIDENTAL DAMAGES INCLUDING WITHOUT LIMITATION DAMAGES FOR LOSS OF PROFITS BUSINESS INTERRUPTION OR LOSS OF INFORMATION ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT EVEN IF QUEST HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES Quest makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and product descriptions at any time without notice Quest does not make any commitment to update the information contained in this document License Credits and Third Party Information See Third_Party_Contributions htm in your JProbe doc installation directory Tutorials November 2009 Table of Contents Introduction to This Guide a ra aaea ae a a eaa oraaa aa Aaea San EEEE ainiai 7 About JPrOBE iiia EA Ea E EEEE aAA E aA EES aiani als aaa 8 About This Guida Saien area a A AENA KNE E N A E AAAA 8 JProbe Documentation Suite c scccsnccsaveravarcesinsaen acne RNE 9 Core Documenitation Setini ieee ieie EA NE SN E ONNEEN EEES Ria 9 Feedback on the Documentations sasra a a 10 Text COVE OS a e aE nena A A a ENER at aTa A EE AARAA a EA aA EEE raia 10 About Quest Software INC hera A A A 10 Contacting Quest SOftWATE sisses aniria deacessseseas baaccisscaesstensastpeetvsatians APARAN A EE aR a ate ARRE 11 Contacting Quest Supporte E E E E EE E
45. K After a few seconds the JProbe Console connects to the JProbe Analysis Engine then the Runtime Summary view appears with the Memory Pools tab on the foreground ia Click Set Recording Level on the toolbar In the Set Recording Level dialog box select Record Allocations and Stack Traces For All Instances then click OK In the Leak Example program window click the Add button ten times Ten buttons numbered 0 to 9 are added on the program window Memory Analysis Demos 21 LeakExample Tutorial Leak Example 6 Click the Remove button ten times The ten buttons are deleted from the program window 7 Click Set Recording Level x on the toolbar 8 Inthe Set Recording Level dialog box select Data Recording Off then click OK JProbe takes a snapshot and displays it in the Snapshots Navigator 9 Close the Leak Example program window JProbe disconnects from the running session After a few seconds the Instances view appears displaying instances that were created during the use case Note If a different snapshot is already opened in the JProbe Console the new snapshot taken does not open automatically To open it right click the snapshot name in the Snapshot navigator and select Open Snapshot Step 3 Identifying Loitering Objects In this step you look for loitering objects in the heap Based on the hypothesis you should expect the Recorded Count for the JButton class to be zer
46. L_HOME user_projects domains gamepack bin directory or other directory if you made changes in the Configuration Wizard and prepare to run the Game Pack in JProbe Building and Deploying Game Pack on BEA WebLogic Server 10 3 If you want to make any changes in the Game Pack source files then you have to build a new Game Pack EAR file using the updated code and deploy the new EAR file instead To correctly build the Game Pack code with latest EJB 3 0 specification dependency libraries for JEE server the classpath J2E EServer property must contain paths to the following JAR files existing in the BEA WebLogic Server 10 3 installation directory e api jar e javax persistence_1 0 0 0_1 O jar 106 JProbe Tutorials Alternatively you can copy the WebLogic Java EE 5 libraries javax persistence_1 0 0 0_1 0 jar and api jar in lt JBPROBE_HOME gt gamepack lib directory no property setting is required in this case To build and deploy the Game Pack demo on BEA WebLogic Server 10 3 1 Inthe lt JPROBE_HOME gt demos gamepack build directory edit the build properties file a Update classpath J2EEServer property with the paths to the following files lt WLS_HOME gt wlserver_10 3 server lib api jar lt WLS_HOME gt modules javax persistence_1 0 0 0_1 0 jar b Delete the pound sign from the J2EEServer WebLogic10 3 statement c Add a pound sign in front of the other J2EEServer
47. NIX or Linux shell from the directory where you saved the startup script run_WithJProbe sh JProbe Game Pack for JavaEE 119 Advanced Game Pack Evaluation JProbe Execution Console opens and the application server and the Game Pack application start JProbe connects to the Game Pack application and the Runtime Summary view opens in the Console Step 2 Logging in to Game Pack In this step you log in to the Game Pack demo 1 2 Open a Web browser and go to http localhost S8080 gamepack The Game Pack Demo login page appears Enter your User ID and Password then click Login Note The first time you do this you need to create a user name and password for yourself For more information see Creating a User Account for Game Pack on page 134 Alternatively you can use the default user ID password admin admin You are now ready to run a Memory analysis session Step 3 Running the Session In this step you turn on garbage monitoring so that you can see how many objects are garbage collected during your use case You work through a use case by playing three consecutive games It does not matter for the analysis whether you win or lose the games However it is important that you start a use case before you begin to play or JProbe will not perform a garbage collection After you have played three games you end the use case and JProbe takes a snapshot To run a game with the Object Cycling fault 1 2 In the Game P
48. Pack Demo on page 68 e System Requirements on page 69 e Setting Environment Variables on page 69 Installing the Game Pack Demo For detailed installation instructions see the J Probe Installation Guide If you chose to install examples during the JProbe installation the Game Pack demo files are installed automatically in the following directory structure JPROBE_HOME demos gamepack build Build and class files geronimo tomcat Geronimo Tomcat 2 1 application server pre configured with the JProbe Game Pack application lib This directory is initially empty You can place here any Java EE library API JAR files you need in order to compile the Game Pack code STC Source code support Support files Includes a deployment subdirectory which contains EAR files for deploying Game Pack on all supported application servers JProbe Game Pack for JavaEE 69 Getting Started with the Game Pack Demo System Requirements The Game Pack demo requires the following environment e JProbe v 8 3 e One of the following operating systems e Microsoft Windows 2003 or XP PRO SP2 or later e Red Hat AS 4 0 or 5 x e Sun Solaris SPARC 9 0 or 10 0 e IBM AIX 5L 5 3 or 6 1 e One of the following application servers e Apache Geronimo 2 1 4 with Jetty 6 e Apache Geronimo 2 1 4 with Tomcat 6 e JBoss 5 1 0 e BEA WebLogic Server 10 3 e BEA WebLogic Server 11g e Java EE SDK 1 6 0 or later e One of the followi
49. Provided WebLogic Template JAR File To deploy the JProbe Game Pack on Oracle WebLogic Server 11g you use the WebLogic Configuration Wizard The following procedure assumes that you have successfully installed and configured Oracle WebLogic Server 11g and JProbe v 8 3 To deploy the Game Pack demo on Oracle WebLogic Server 11g 1 Start the WebLogic Configuration Wizard e On Windows click Start gt Programs gt Oracle Weblogic gt WebLogic Server 11g gt Tools gt Configuration Wizard e On UNIX systems execute java jar configwiz jar in the WL_HOME wlserver_10 3 common lib directory Select the Create a new WebLogic domain check box and click Next Select the Base this domain on an existing template check box Click Browse and navigate to lt JPROBE_HOME gt demos gamepack support deployment Weblogic10 3 templates domains directory select gamepack jar and click OK Click Next Specify the directory where the WebLogic domain will be created The default is in the user_projects domain directory of your WL_HOME The default domain name is gamepack You can leave the default directory or change it Specify the directory where WebLogic Applications will be stored The default is the user_projects applications directory of your WL_HOME You can leave the default directory or change it Configure the User name and User password and click Next default is recommended Specify the server start mode by selecting the Devel
50. Web browser Note If the Web browser does not open the welcome page you can open a browser and type http localhost 8686 gamepack The default value of the pre configured Geronimo HTTP port is 8686 The Game Pack welcome startup page appears JProbe connects to the Game Pack application and the Runtime Summary view opens in the Console Step 2 Logging in to Game Pack In this step you log in to the Game Pack demo 1 Inthe Welcome to the JProbe Game Pack Demo Application page click Start using Game Pack The Game Pack demo login page appears 2 Enter your User ID and Password then click Login Note The first time you do this you need to create a user name and password for yourself For more information see Creating a User Account for Game Pack on page 134 Alternatively you can use the default user ID password admin admin You are now ready to run a Memory analysis session Step 3 Running the Session In this step you work through a use case by playing three consecutive games It does not matter for the analysis whether you win or lose the games However it is important that you start a session before you begin to play or JProbe will not perform a garbage collection After you have played three games you end the session and JProbe takes a snapshot To run a game with the Loitering Objects fault 1 Inthe Game Pack demo click Play beside either Minesweeper or Match Game Note Both games have the same loitering ob
51. _3 0_spec 1 1 1 jar lt GERONIMO_HOME gt repository org apache geronimo specs geron imo jta_1 1_spec 1 1 1 geronimo jta_1 1_spec 1 1 1 jar lt GERONIMO_HOME gt repository org apache geronimo specs geron imo servlet_2 5_spec 1 2 geronimo servlet_2 5_spec 1 2 jar Alternatively you can set the classpath J2EEServer property to point to the Geronimo specs repository classpath J2EEServer lt GERONIMO_HOME gt repository org apache geronimo specs b Delete the pound sign from the J2EEServer Geronimo statement c Add a pound sign in front of the other J2EEServer statements that is J2EEServer JBossWithTomcat and J2EEServer WebLogic10 3 d Save the file 2 If it is not already started start the Apache Geronimo application server using the lt GERONIMO_HOME gt bin startup bat file 3 To build and deploy the Game Pack code open a command window navigate to the lt JPROBE_HOME gt demos gamepack directory and enter the following command ant f build build xml deploy The Gamepack ear file is created in the lt JPROBE_HOME gt demos gamepack dist directory and the Game Pack application is deployed on the Geronimo application server 4 To view the Game Pack open a browser and type http localhost lt port gt gamepack where lt port gt is Geronimo s http port number The default value is 8080 JProbe Game Pack for JavaEE 101 Advanced Game Pack Evalua
52. a heap long after their usefulness is gone In this tutorial you see how you can reclaim memory by removing loitering GameHandler objects The following table summarizes the types of information you need to know before starting this tutorial Program Game Pack demo Match Game Use Case Play a few games without quitting Architecture When the Start button is selected create a GameHandler object to run the game Hypothesis The GameHandler object is removed from the heap when the game ends The tutorial walks you through the following steps e Step 1 Starting the Session and the Game Pack e Step 2 Logging in to Game Pack e Step 3 Running the Session e Step 4 Shutting Down the Server e Step 5 Identifying Loitering Objects e Step 6 Investigating Loitering Objects e Step 7 Running the Session with Improved Code 72 JProbe Tutorials Step 1 Starting the Session and the Game Pack In this step you start the Geronimo Tomcat server using the pre defined startup script shipped with JProbe then connect JProbe to the Game Pack application running on this server To start the session from command line 1 Type in the following command depending on your platform In Windows lt JPROBE_HOME gt demos settings startWith_MemAnalysis bat In a UNIX or Linux shell lt JPROBE_HOME gt demos settings startWith_MemAnalysis sh The Geronimo Tomcat application server and the Game Pack application start in a command li
53. ack demo select Play beside Match Game Select the Object Cycling option Note Clicking the link displays the option s definition In the JProbe Runtime Summary view click Set Recording Level on the toolbar In the Set Recording Level dialog box select Record Allocations Stack Traces and Garbage Data For All Instances and click OK In the Game Pack demo click Start and play the game When the game ends play the game twice more without quitting for a total of three complete games Click Quit 120 JProbe Tutorials 8 Inthe Runtime Summary view click Set Recording Level on the toolbar 9 In the Set Recording Level dialog box select Data Recording Off then click OK JProbe takes a snapshot and displays it in the Snapshots Navigator 10 In the Snapshots Navigator right click this snapshot select Save Snapshot As and navigate to where you want to save the snapshot 11 Name the snapshot object_cycling and click Save The new name is displayed in the Snapshots Navigator 12 Click Detach From Session F Note If a different snapshot is already opened in the JProbe Console the new snapshot taken does not open automatically To open it right click the snapshot name in the Snapshot navigator and select Open Snapshot 13 On the Game Pack demo page click Logout then close the browser Step 4 Identifying Object Cycling In this step you look for classes and methods that allocate short lived obje
54. al The Game Pack Performance tutorial Performance Bottleneck Tutorial describes how to investigate a performance bottleneck using the JProbe Performance analysis tool and the pre defined Demo Gamepack Performance Analysis configuration Performance Bottleneck Tutorial The Minesweeper game can be played in the Method Time mode This mode demonstrates a performance bottleneck caused by an inappropriate algorithm that is used for rendering the Minesweeper game board as one large image For comparison you can play the game in the Normal mode which creates the game board as a table containing HTML links to images The following table summarizes the types of information you need to know before starting this tutorial Program Game Pack Demo Minesweeper Game Entry point of interest GameController doGet Use Case Run minesweeper and select one tile Architecture Method Time The game board is constructed with images on the server side encoded as a single image and sent to the browser You may notice the image jumps when a tile is selected Normal The game board is created as a table of links to images Hypothesis Encoding is slow Creating the game board with links to images will be faster and smoother especially if the images are cached by the browser The tutorial walks you through the following steps e Step 1 Starting the Session and the Game Pack e Step 2 Logging in to Game Pack e Step 3 Running the Session e Step 4
55. and Deploying Game Pack on Geronimo Creating a Database for the Game Pack Demo You must create a database before deploying Game Pack on an Apache Geronimo application server The following procedure assumes that you have successfully installed a supported version of Apache Geronimo To create a database for the Game Pack demo 1 Start the Apache Geronimo application server using the lt GERONIMO_HOME gt bin startup bat file 2 Open the Geronimo Console by typing http Nocalhost S080 console in your browser window 3 Log in to the Geronimo Console using your username and password The default username password is system manager 4 Inthe Console Navigation pane click the Embedded DB gt DB Manager link 5 Inthe Run SQL pane type in a name for the new database for example GamepackbB and click Create JProbe Game Pack for JavaEE 97 Advanced Game Pack Evaluation GIG R NIMO e insole amp B se e 7 amp Kd i a The database is created and its name GamepackDB appears in the DB Viewer pane in the Database List 6 Inthe Run SQL pane select GamepackDB from the Use DB list 7 Using a text editor of your choice open the lt JPROBE_HOME gt demos gamepack support deployment Geronimo db gamepack sql file provided with the demo copy its content into the SQL Commands field in the Geronimo Console then click Run SQL The GamepackDB table is now initialized and ready to use 8 Log out of the Ge
56. asurehunt Demo For detailed installation instructions see the JProbe Installation Guide If you chose to install examples during the JProbe installation the Treasurehunt demo files are installed automatically in the following directory structure JPROBE_HOME demos treasurehunt data Maven STC Using the Treasurehunt Demo Input data required to run the treasurehunt demo An example of how to integrate JProbe with Treasurehunt using the Maven build tool These files give you a better understanding of how JProbe can be run as part of your build process using Maven Source code The Treasurehunt demo application helps you understand how to use the JProbe Ant Tasks in your build file For detailed information see the Treasurehunt Tutorials in the JProbe Ant Tasks User Manual Index A about JProbe 8 about Quest Software 10 Adventure tutorial 59 C code coverage tutorial 89 129 contacting Quest 11 coverage analysis demos summary of 58 tutorials case effectiveness Java SE 59 Java EE 89 129 coverage effectiveness Java SE tutorial 59 creating a database 96 creating Game Pack user accounts 134 D database creating 96 deadlock Java SE tutorial 42 demos Java EE Game Pack 67 Java SE coverage analysis 57 memory analysis 13 performance analysis 39 Treasurehunt 137 deploying Game Pack demo on Apache Geronimo 95 Index 139 BEA WebLogic Server 10 3 103 JBoss 101 Oracle WebLogic S
57. at are called very rarely You also need to evaluate the overall impact on the runtime of the program If an inefficient algorithm takes a total of a few seconds to execute you may make it run faster but the impact on the overall runtime of the program would be negligible Game Pack Coverage Analysis Tutorial The Game Pack Coverage tutorial Code Coverage Tutorial describes how to assess the code coverage of your Game Pack program using the JProbe Coverage analysis tool and the pre defined Demo Gamepack Coverage Analysis configuration Code Coverage Tutorial This basic tutorial shows you how to evaluate the effectiveness of two test cases for the Game Pack Minesweeper game In the first case play the Minesweeper game in Normal mode In the second case play the Minesweeper game in Loitering Object mode At the end compare the results obtained during the two test cases and measure the code coverage The following table summarizes the types of information you need to know before starting this tutorial Program Game Pack Demo Minesweeper Game Test Case 1 Run Minesweeper in Normal mode Test Case 2 Run Minesweeper in Loitering Object mode The tutorial walks you through the following steps 90 JProbe Tutorials Step 1 Step 1 Starting the Session and the Game Pack Step 2 Logging in to Game Pack Step 3 Running the Session Step 4 Shutting Down the Server Step 5 Merging the Test Results Step 6 Assessing Your Test C
58. bin run_WithJProbe bat e In a UNIX or Linux shell from the directory where you saved the startup script run_WithJProbe sh JProbe Execution Console opens and the application server and the Game Pack application start JProbe connects to the Game Pack application and the Runtime Summary view opens in the Console Step 2 Logging in to Game Pack In this step you log in to the Game Pack demo 1 Open a Web browser and go to hAttp Nocalhost 8080 gamepack The Game Pack Demo login page appears 2 Enter your User ID and Password then click Login Note The first time you do this you need to create a user name and password for yourself For more information see Creating a User Account for Game Pack on page 134 Alternatively you can use the default user ID password admin admin You are now ready to run a Performance analysis session Step 3 Running the Session In this step you play the Minesweeper game in Normal mode three consecutive times test case 1 then three more times in Object Loitering mode test case 2 without quitting It does not matter for the analysis whether you win or lose the games For each test case you take a snapshot To run the session for a coverage analysis 1 Perform test case 1 a Inthe Game Pack demo click Play beside Minesweeper b Select the Normal option Note Clicking the link displays the option s definition c Click Start and play the game 132 JProbe Tutorials When the ga
59. build the game board one that does not require that the images be loaded and encoded on the server side Instead the game board is simply a table of HTML links If image caching is enabled in the browser the images are stored and used locally otherwise the links point to images on the Web server To run the session with improved code 1 Repeat Step 1 Setting Up the Session and Starting the Game Pack to Step 3 Running the Session selecting Normal mode instead of the Method Time option and save the snapshot as minesweeper_normal 2 Right click minesweeper_normal and select the Open Snapshot The Summary view appears 3 Select the top method suggested for investigation demos gamepack minesweeper MineSweeperRenderer renderMineMa piImage_Norma1 in the Performance Hotspot section right click and select Investigate The Methods view appears 4 Inthe Call Graph hover over the renderMineMapImage_Normal node to display its tooltip You can see that the Elapsed Method Time is 23 ms and it is called five times The new method renderMineMapImage_Normal runs faster than the original renderMineMapImage_MethodTime method Also the new method does not require the encoding servlet so overall the program is even faster 128 JProbe Tutorials Step 6 Measuring the Performance Improvement You know that the image caching algorithm runs much faster than the original compression algorithm To quantify the improvement use the Snapshot Di
60. cat application server To stop the Geronimo Tomcat server 1 Open a command window and navigate to lt JPROBE_HOME gt demos settings Type in the following command e In Windows startWith_MemAnalysis bat stop e Ina UNIX or Linux shell startWith_MemAnalysis sh stop JProbe Game Pack for JavaEE 75 Quick Game Pack Evaluation 3 Type in Username system 4 Type in Password manager The Geronimo Tomcat application server shuts down and the JProbe Execution Console closes Step 5 Identifying Loitering Objects In this step you look for loitering objects in the heap The Heap Count column is the first place to look In general you should expect objects created during a session to be removed at the end of it In fact the GameHandler objects are not removed and three instances of this object continue to loiter in the heap To identify loitering objects 1 If the loitering_objects snapshot is not open right click it in the snapshot navigator and select Open Instances View The Instances view appears 2 In the Filter Classes field type GameHandler and press Enter to display only the GameHandler class The Heap Count for GameHandler is 3 not 0 zero as hypothesized Step 6 Investigating Loitering Objects In this step you find the live object that continues to hold a reference to the loitering instances of GameHandler in the heap You start in the Instances view then drill down to Instance Detail and
61. ces and Instance Detail views 26 JProbe Tutorials Step 5 Running the Memory Leak Session with Improved Code In this step you need to force the execution of the code that removes the buttons from the buttons array The LeakExample demo contains the fixed line of code you just need to add a program argument to your session settings to activate it Note that in this example removing the loiterer does not free all the memory because the memory calculation includes some recursive references and because other objects in the program continue to need some of the objects referenced by the loiterer After you rerun the session with the fixed code you can clearly see in the Instances view that both the Recorded Count and Dead Count for JButton are now O as predicted by the hypothesis However in a real life scenario where the effect of changes is more widespread you may need to compare the snapshots to see all the differences This tutorial walks you through how to do that comparison To verify the fixed code 1 Inthe JProbe Console click the Configurations tab 2 Click Java Application gt LeakExample The LeakExample_Mem_Settings jpl tab opens in the View area 3 Click Edit The LeakExample_Mem_Settings jpl tab is displayed in edit mode with the Summary tab on the foreground 4 Click the Edit link beside Application Arguments 5 Inthe Java Application tab click the browse button beside the Application Arguments field 6 Int
62. cient algorithm takes a total of a few seconds to execute you may make it run faster but the impact on the overall runtime of the program would be negligible Game Pack Coverage Analysis Tutorial The Game Pack Coverage tutorial Code Coverage Tutorial describes how to assess the code coverage of your Game Pack program using the JProbe Coverage analysis tool JProbe Game Pack for JavaEE 129 Advanced Game Pack Evaluation Code Coverage Tutorial This basic tutorial shows you how to evaluate the effectiveness of two test cases for the Game Pack Minesweeper game In the first case play the Minesweeper game in Normal mode In the second case play the Minesweeper game in Loitering Object mode At the end compare the results obtained during the two test cases and measure the code coverage The following table summarizes the types of information you need to know before starting this tutorial Program Game Pack Demo Minesweeper Game Test Case 1 Run Minesweeper in Normal mode Test Case 2 Run Minesweeper in Loitering Object mode The tutorial walks you through the following steps e Step 1 Setting Up the Session and Starting the Game Pack e Step 2 Logging in to Game Pack e Step 3 Running the Session e Step 4 Merging the Test Results e Step 5 Assessing Your Test Coverage Step 1 Setting Up the Session and Starting the Game Pack You use the JProbe configuration wizard to create the session settings for this example In the setu
63. con window on exit check box and click Run amp Connect The JProbe Execution Console opens then the Network Simulation program starts displaying a window with icons representing elements of a network You are now ready to run a Memory analysis session using the improved code Follow the instructions in Step 2 Running the Network Session to exercise the same use case In the Memory Pools graph the peaks and valleys on the graph are less pronounced which suggests that fewer objects are collected each time the garbage collector runs 36 JProbe Tutorials Memory Pools Mb 6 Memory Pools Eden Space 4 Disurvivor Space tenured Gen Davailable nm 00 00 25 00 00 35 00 00 45 00 00 55 00 01 05 00 01 15 12 In the Instances view if necessary select Dead Count from the Investigate by list 13 In the lower pane click the Dead Count column header twice to sort the table by the classes with the most garbage collected instances Filter Classes a 535 5351 Name Recorded Count Heap Count Recorded Memory Heap Memory Keep Alive Size Dead C Y Dead Memory Total 5 025 17 252 106 752 1 067 088 1 067 088 8 420 230 048 java awt Dimension o 0 o 0 0 3 367 53 872 A sun java2d d3d D3DSurfaceData D3DWindo 0 o 0 0 0 1 080 21 600 S java awt Rectangle 0 0 o 0 o 862 20 688 java lang Object 5 338 25 760 40 864 123 024 417 32 512 sun awt EventQueueltem 0 0 0 0 0 335 5
64. ct JProbe Game Pack for JavaEE 79 Quick Game Pack Evaluation The JProbe Execution Console opens the Geronimo Tomcat application server and the Game Pack application start and the Welcome to the JProbe Game Pack Demo Application page opens in a Web browser Note If the Web browser does not open the welcome page you can open a browser and type http localhost 8686 gamepack The default value of the pre configured Geronimo HTTP port is 8686 The Game Pack welcome startup page appears JProbe connects to the Game Pack application and the Runtime Summary view opens in the Console Step 2 Logging in to Game Pack In this step you log in to the Game Pack demo 1 Inthe Welcome to the JProbe Game Pack Demo Application page click Start using Game Pack The Game Pack demo login page appears 2 Enter your User ID and Password then click Login Note The first time you do this you need to create a user name and password for yourself For more information see Creating a User Account for Game Pack on page 134 Alternatively you can use the default user ID password admin admin You are now ready to run a Memory analysis session Step 3 Running the Session In this step you turn on garbage monitoring so that you can see how many objects are garbage collected during your use case You work through a use case by playing three consecutive games It does not matter for the analysis whether you win or lose the games However it
65. cts The Garbage Collections chart in the GC Data tab displays steep spikes which means that some set of objects is garbage collected soon after being created In the Instances view look for classes with high Dead Count values and no or very few instances still alive In this example you can see that many instances of StringBuffer were allocated and garbage collected None of the instances are still alive When you review the results you see that most of the StringBuffer objects were allocated by _StringConcatenation methods in the MatchGameRenderer class To identify short lived objects 1 Ifthe object_cycling snapshot is not open right click it in the Snapshots Navigator and select Open Instances View The Instances view appears 2 Select Dead Count from the Investigate by list and sort the table by Dead Count You can see that many String and StringBuffer instances are immediately garbage collected that is high Dead Count values and low Recorded Count values JProbe Game Pack for JavaEE 121 Advanced Game Pack Evaluation 3 Drill into the Merged Allocation Points and Call Traces views by selecting the StringBuffer instance right clicking and selecting the Open Merged Allocation Points View and Open Call Traces View respectively 4 Inthe Merged Allocation Points view right click My Code and select Replace Category with More Detail then sort by Cumulative Count You can see that most of the StringBuffer objects were a
66. d a startup script click Save amp Integrate 13 Click Save to save the configuration file PerformanceBottleneck_Perf_Settings jpl into your working directory Tip Itis a good practice to save the configuration files into a directory other than the JProbe installation directory for example C JProbeFiles The Integration Wizard dialog box appears displaying the integration status 14 In the Integrate tab click the browse button and navigate to the location where you want to save the startup script for example in Windows run_WithJProbe bat and in UNIX Linux systems run_WithJProbe sh then click Save Tip Itis a good practice to save the script files into a directory which is recommended by the integration Status dialog for example in this case the recommended path is C lt jboss_home gt bin directory 15 When the integration is complete click Next The Run Configuration tab is displayed 16 Select the Close syscon window on exit check box to automatically close the jpsyscon window after the termination of the launched script if the program exits normally JProbe Game Pack for JavaEE 125 Advanced Game Pack Evaluation 17 To run your application with JProbe using the startup script click Run amp Connect Note To start JBoss using the startup script In Windows C lt jboss_home gt bin run_WithJProbe bat e In a UNIX or Linux shell from the directory where you saved the startup script run_WithJPr
67. demos coverage directory This chapter contains the following sections Summary of Demos for Coverage s ssessscssssescsesssesesnsesesnseseenessteneeaeesesateatseaesnseaeeneratenseateneeatens 58 ONS e E E EEE A EE E A T aoe 59 58 JProbe Tutorials Summary of Demos for Coverage The following table describes the purpose of the example applications Java SE Application Adventure class Purpose A text based adventure game in which you navigate through a house The application ships with two test case input files The test cases do not provide 100 coverage of the program code More Information See the notes in Adventure java Tutorial Adventure Tutorial on page 59 SwitchCaseTest class This example demonstrates conditional coverage using a simple switch case statement See the notes in SwitchCaseTest java TryCatchFinallyTest class This example demonstrates how JProbe tracks try catch finally blocks See the notes in TryCatchFinallyTest java JProbe also ships with a Java EE demo application called JProbe Game Pack Demo for Java EE For more information see JProbe Game Pack for JavaEE on page 67 Coverage Analysis Demos 59 Adventure Tutorial Adventure Tutorial This basic tutorial shows you how to evaluate the effectiveness of two test cases for a text based adventure game The test cases are supplied as text files which are specified in program arguments The
68. e the new snapshot taken does not open automatically To open it right click the snapshot name in the Snapshot navigator and select Open Snapshot On the Game Pack demo page click Logout then close the browser Shutting Down the Server In this step you close the Geronimo Tomcat application server To stop the Geronimo Tomcat server 1 Open a command window and navigate to lt JPROBE_HOME gt demos settings Type in the following command e In Windows startWith_MemAnalysis bat stop e Ina UNIX or Linux shell startWith_MemAnalysis sh stop JProbe Game Pack for JavaEE 81 Quick Game Pack Evaluation 3 Type in Username system 4 Type in Password manager The Geronimo Tomcat application server shuts down and the JProbe Execution Console closes Step 5 Identifying Object Cycling In this step you look for classes and methods that allocate short lived objects The Garbage Collections chart in the GC Data tab displays steep spikes which means that some set of objects is garbage collected soon after being created In the Instances view look for classes with high Dead Count values and no or very few instances still alive In this example you can see that many instances of StringBuffer were allocated and garbage collected None of the instances are still alive When you review the results you see that most of the StringBuffer objects were allocated by _StringConcatenation methods in the MatchGameRenderer class
69. e Analysis The Gamepack_Cov_Settings jpl tab is displayed in the View area 3 Click through the configuration tabs to review the settings Note These pre defined settings cannot be modified or deleted Also you do not need to integrate your application with JProbe because a startup script is already provided for this demo 4 Torun the Game Pack startup script and also connect the JProbe Console click Run amp Connect The JProbe Execution Console opens the Geronimo Tomcat application server and the Game Pack application start and the Welcome to the JProbe Game Pack Demo Application page opens in a Web browser Note If the Web browser does not open the welcome page you can open a browser and type http localhost 8686 gamepack The default value of the pre configured Geronimo HTTP port is 8686 The Game Pack welcome startup page appears JProbe connects to the Game Pack application and the Coverage Session view opens in the Console Step 2 Logging in to Game Pack In this step you log in to the Game Pack demo 1 Inthe Welcome to the JProbe Game Pack Demo Application page click Start using Game Pack The Game Pack demo login page appears 2 Enter your User ID and Password then click Login Note The first time you do this you need to create a user name and password for yourself For more information see Creating a User Account for Game Pack on page 134 Alternatively you can use the default user ID password adm
70. e file Hypothesis The program does not create unnecessary temporary objects The tutorial walks you through the following steps e Step 1 Setting Up the Network Session e Step 2 Running the Network Session e Step 3 Identifying Large Allocations of Short Lived Objects e Step 4 Investigating Large Allocations of Short Lived Objects e Step 5 Running the Network Session with Improved Code Memory Analysis Demos 29 Network Tutorial Step 1 Setting Up the Network Session To run a garbage collection analysis you need to set up the session in the JProbe Console The following procedures mention only the settings that you need to change or verify If a setting is not mentioned leave it blank or in its default state The procedure assumes that you are running JProbe locally on your computer To set up the session 1 2 In the JProbe Console click the Configurations tab Expand Java Application You can see that JProbe includes a pre defined configuration file for the Network demo Click Demo Network Memory Analysis The Network_Mem_Settings jpl tab is displayed in the View area Click through the configuration tabs to review the settings Note These pre defined settings cannot be modified or deleted Also you do not need to integrate your application with JProbe because a startup script is already provided for the Network demo To run your application startup script and also connect the JProbe Console click Run amp Con
71. e following table summarizes the types of information you need to know before starting this tutorial Program Game Pack Demo Minesweeper Game Entry point of interest GameController doGet Use Case Run minesweeper and select one tile JProbe Game Pack for JavaEE 123 Advanced Game Pack Evaluation Architecture Method Time The game board is constructed with images on the server side encoded as a single image and sent to the browser You may notice the image jumps when a tile is selected Normal The game board is created as a table of links to images Hypothesis Encoding is slow Creating the game board with links to images will be faster and smoother especially if the images are cached by the browser The tutorial walks you through the following steps Step 1 Setting Up the Session and Starting the Game Pack Step 2 Logging in to Game Pack Step 3 Running the Session Step 4 Identifying the Performance Bottleneck Step 5 Running the Session with Improved Code Step 6 Measuring the Performance Improvement Step 1 Setting Up the Session and Starting the Game Pack You use the JProbe configuration wizard to create the session settings for this example In the setup procedure only the settings that you need to change or verify are mentioned If a setting is not mentioned leave it blank or in its default state The following procedure assumes that you are running JProbe locally on your computer To set up the session a
72. e gt demos gamepack src demos gamepack web game select EJBControllerImpl java and click Open The Source view opens highlighting line 174 of the code This line represents the method call from the getGameHandlerRemote method to the application server s create method which creates the beans Now that you found the method that creates the loitering GameHand1ler objects you are close to finding out where the objects should be removed Scrolling down to line 185 you find that the resetGameHandlerRemote method is the problem method When the Loitering Objects mode is selected the 116 JProbe Tutorials _gameHandlerRemote removeObject method is not called so the references to the GameHandler objects are never removed Tip Itis good programming practice to pair your calls to create and remove objects close together Step 6 Running the Session with Improved Code You can re run Minesweeper or Match Game in Normal mode with the corrected code Repeat Step 1 Setting Up the Session and Starting the Game Pack through Step 3 Running the Session selecting Normal mode instead of Loitering Objects and not re naming the snapshot You will see in the Instances view that the Heap Count for GameHandler is now 0 as predicted by the hypothesis This example demonstrates how to use JProbe to identify and remove loitering objects from your code Object Cycling Tutorial The Match Game offers an Object Cycling mode The Objec
73. e text area See the notes in MethodCalls java Objects class Compares the performance of using objects versus primitives See the notes in Objects java Performance Analysis Demos 41 Summary of Demos for Performance Java SE Application Polynomial class Purpose The application calculates a polynomial expression using one of two algorithms This example shows how you can use JProbe to compare performance and identify the more efficient algorithm More Information See the notes in Polynomial java Tutorial Polynomial Tutorial on page 47 Strings class This application uses two alternative approaches to strip embedded tabs from strings You can track the two methods and compare their performance See the notes in Strings java JProbe also ships with a Java EE demo application called JProbe Game Pack Demo for Java EE For more information see JProbe Game Pack for JavaEE on page 67 42 JProbe Tutorials Philosopher s Diner Tutorial In this tutorial you investigate a deadlock situation The symptom of the problem is that the program hangs and does not terminate Based on the classic Dining Philosophers deadlock demonstration the tutorial program simulates five Philosophers seated around a table each with a bowl of rice in front of him or her To eat their rice there are only five chopsticks available to share among the Philosophers one placed between
74. each pair of Philosophers To eat the rice a Philosopher must have two chopsticks Once a Philosopher is finished using a chopstick that chopstick is available to the Philosopher beside him or her The eventual result of this sharing is a deadlock when each Philosopher waits indefinitely for another chopstick to become available This tutorial illustrates how you can detect where a thread causing a deadlock is executing within your own code The tutorial walks you through the following steps e Step 1 Setting Up the Diner Session e Step 2 Running the Diner Session e Step 3 Investigating the Deadlock Step 1 Setting Up the Diner Session In this step you set up a session to detect deadlock situations You use the JProbe Console to create the session settings The following procedures mention only the settings that you need to change or verify If a setting is not mentioned leave it blank or in its default state The procedure assumes that you are running JProbe locally on your computer To set up the session 1 Inthe JProbe Console click the Configurations tab 2 Expand Java Application You can see that JProbe includes a pre defined configuration file for the Diner demo 3 Click Demo Diner Performance Analysis The Diner_Perf_Settings jpl tab is displayed in the View area Performance Analysis Demos 43 Philosopher s Diner Tutorial 4 Click through the configuration tabs to review the settings Note These pre defined
75. eate a user account 1 a FF Ww PN In the Game Pack demo home page click Sign up as new user Type a user name and password in the User ID and Password fields Re type the password in the Re enter Password field Type the name you want to use for the games in the Name field Click Sign up The Game Pack demo home page re appears The name you typed in the Name field appears in the top left corner JProbe Game Pack for JavaEE 135 Game Pack Known Issues Hi New User Your latest score is 10 points RA Select a game to play Minesweeper Play Match Game Play Config Tutorials Logout You can now proceed to play Minesweeper or Match Game Game Pack Known Issues The following known issues have been identified The Game Pack may not work with the evaluation version of WebLogic Server Use a fully licensed version of WebLogic or use JBoss Minesweeper handles one selection at a time and does not buffer multiple tile clicks Right clicking Minesweeper and selecting Open in New Window may cause unexpected results Opening multiple browser sessions for the same user may cause point calculation issues 136 JProbe Tutorials JProbe Treasurehunt This section provides information about the Treasurehunt demo software that ships with JProbe This chapter contains the following sections Installing the Treasurehunt Demo Using the Teasurehunt Deno Aten dian avcaas a 138 138 JProbe Tutorials Installing the Tre
76. ecsscieesecsecntucecateutscravesartectateutedroacteececteet acsuersnitie nitecsntcueosneaetirad 57 Summary of Demos for Coverage vic saccedieren nirai iie AEE ANA EEE EEN a 58 Adventure Tutoriala iei EaR aaar aa a aa a aaa 59 Step T Setting Your Global Options isn a a 59 Step 2 Setting Up the Session for the First Test Case scessesesseseesesseesseseesneesteeseesneesneenteeneeneestesneesteeneesees Step 3 Running the First Test Case issii iii i ieri E E rerin Step 4 Setting Up and Running the Second Test Case Step 5 Merging the Test Case Results escssessesessecsseseestecseesesseesseesneensecnsesteessesseessecseeaseestesneesteestesseesnesees Step 6 Assessing Your Test Case Coverage cessesessesseseesessssneesnssneesnseseeneesueestesneeseesiesneesessuesiesieesteenaesees JProbe Game Pack for JavaEE sssssssssssssessssseesseesesssesessteaeeateeeesnsesesseesnseaeeseeseeneeatentsateetsaneeteanseeeteaneeenanees 67 Getting Started with the Game Pack De m0 ssssssssesssssessessessessessessessessnssussussussussssensesesacenesaneateaesaeeasesesaneateateateateesees 68 Installing the Game Pack Demo System Requirements minerare ARE O E R AVO E EEV Setting Environment Variables issis sidii riii vieii siai averii E i riea Quick Game Pack Eval atio nierien ninna ain ach N en TEATR 70 Game Pack Memory Analysis Tutorials oi iccistsecrattnansiassessietscecaspiaessaitiia apsaiesanie dees aaa eai AARAA EEE TETESI 71 Game Pack Performance Anal
77. ectory Tip Itis a good practice to save the configuration files into a directory other than the JProbe installation directory for example C JProbeFiles The Integration Wizard dialog box appears displaying the integration status Memory Analysis Demos 19 LeakExample Tutorial 19 In the Integrate tab use the browse button to navigate to your working directory and click Save Tip Itis a good practice to save the script files into a directory other than the JProbe installation directory for example C JProbeFiles JProbe validates the configuration file and creates a startup script file for example in Windows LeakExample bat and in UNIX Linux systems LeakExample sh Integration Wizard Integrate Integrating LeakExample Integration status Checking JPL file existence done Saving current settings in JPL file done Validating JPL file with jplauncher done Validating working directory done Generating startup script text done Please save JProbe startup script file to continue Updating permissions for the script file done Script file C JProbe workspace tutorials_jprobe_83 LeakExample bat amp JPL file C JProbe workspace tutorials_83 LeakExample_Mem_Settings jpI are generated successfully To launch your application with JProbe run this script from the command line Integration complete Press Next to open Run Configuration tab for executing JProbe startup script
78. eeseseeseeseseesssneesteeneees 31 Step 4 Investigating Large Allocations of Short Lived Objects cesssessesssesssseeeseeseeeseesessesneesteentestenneesns 32 Step 5 Running the Network Session with Improved Code cssesssssessecseesseseensessesteeseeseesteseesesseeseesteeneenss 34 4 JProbe Tutorials Performance Analysis DeMOS sssscsssssssrsscsesrsseesenrsneesennsneesenraneeseoraneesennsneeseoraneesennaneetentsneatennaneenennaneates 39 Summary of Demos fonPerormance seiras aaaeeeaa anaa aa naana a aaa Es PaA LDAA aaa Aaa APAE a Aaaa DEEE EEEn Philosopher s Diner Tutonalsitesarana n E E ana Step 1 Setting Up the Diner Session Step 2 Running the Diner Session i sissiriniriinninnrinii ai n i Step 3 Investigating the Deadlock s sesscs20 cactcavieeavtccrnivonsvavatavnnaileanemitenkiniwelwaninmwaaratal Polynomial Tutorial e aie a in eel oes ek Gee a eevee ie a ee 47 Step 1 Setting Up the Polynomial SeSSiION nennen na a 48 Step 2 Running the Polynomial S SSiOnssitssicsesiesuitssssari sissies sararoutasacnatetn seein qiaacaeatigeiied 51 Step 3 Identifying and Investigating the Performance Bottleneck c ss csscsesssssessesseeseeeseseesssesessesesenseteeesaees 52 Step 4 Running the Polynomial with Improved Code Step 5 Measuring the Performance Improvement cessesecseesseestesseesseesnesseesneesteeneesneestesneenteestesneestesneeeteenaesees Coverage Analysis Demo wsiisicsccsccsccscesccsecsctecsu
79. erver 11g 106 Diner tutorial 42 documentation core 9 feedback 10 suite 9 E environment variables setting 69 G Game Pack advanced evaluation 95 building the demo 99 Coverage Analysis tutorial 89 128 creating a database 96 creating user accounts 134 deploying demo 95 getting started 68 installing 68 known issues 135 Memory Analysis tutorials 71 110 Performance Analysis tutorial 83 122 quick evaluation 70 running with JProbe 109 setting environment variables 69 system requirements 69 140 JProbe Tutorials Geronimo building the demo 99 creating a database 96 inefficient algorithm Java SE tutorial 47 installing Game Pack 68 Treasurehunt 138 J Java coverage effectiveness 59 Java EE code coverage tutorial 89 129 loitering objects tutorial 71 110 object cycling tutorial 77 116 performance bottleneck tutorial 83 122 Java SE deadlock tutorial 42 inefficient algorithm tutorial 47 leak example tutorial 16 object over allocation 28 JProbe community 12 L LeakExample tutorial 16 Loitering Objects tutorial 71 110 M memory analysis demos summary of 14 tutorials leak example Java SE 16 loitering objects Java EE 71 110 object cycling Java EE 77 116 object over allocation Java SE 28 memory leak Java SE tutorial 16 N Network tutorial 28 O Object Cycling Java EE tutorial 77 116 object over allocation Java SE tutorial 28 P performance analysis demos summary of 40 tutorials bo
80. ettings for this tutorial The following procedures mention only the settings that you need to change or verify If a setting is not mentioned leave it blank or in its default state The procedure assumes that you are running JProbe locally on your computer To set up the session 1 In the JProbe Console click Configurations gt New Configuration The New Configuration Wizard dialog box appears Click Java Application gt Java Application Provide a name for this configuration in the Configuration Name text box for example LeakExample then click Next The Java Application tab is displayed In the Main Class area select the Execute a class check box Click the browse button in the Main Class area and navigate to the LeakExample class file in the lt jprobe_home gt demos memory Neakexample directory Click OK The following information is displayed e Main Class demos memory leakexample LeakExample e Working Directory lt jprobe_home gt Click the browse button beside the Classpath field In the Classpath dialog box click Add Working Directory then click OK The working directory appears in the Classpath field Click Next The Select a Java Virtual Machine tab is displayed If you want to change the default JVM click the browse button beside the Java Executable field select another JVM in the Java Virtual Machines dialog box then click OK Alternatively you can use the JVM that is installed with JProbe
81. example In the setup procedure only the settings that you need to change or verify are mentioned If a setting is not mentioned leave it blank or in its default state The following procedure assumes that you are running JProbe locally on your computer To set up the session and start Game Pack 1 On the JProbe Console click Configurations gt New Configuration The New Configuration Wizard dialog box appears Click JBoss gt JBoss v5 x Provide a name for this configuration in the Configuration Name text box for example ObjectCycling then click Next Type the path to your server startup script in the text field or click the browse button and navigate to it then click Next In the My Code tab in the Elements area type the path to the deployed gamepack ear file for example lt jprobe_home gt demos gamepack support deployment JBoss WithTomcat gamepack ear or click the browse button J and navigate to it Click Create Filters The table is populated with the filters available for your application Select the My Application Filters check box 118 JProbe Tutorials 10 1 12 13 14 15 16 All application filters are now selected and Action set to include JProbe can use these application filters as default data collection filters when performing a Memory analysis Specify a Category Program Name then click Next In the Analysis Type tab select Memory Analysis then click Next Click N
82. ext again to pass the Advanced JProbe Options tab The Summary tab is displayed It presents a summary of the settings defined for your configuration To create a JPL file and a startup script click Save amp Integrate Click Save to save the configuration file ObjectCycling_Mem_Settings jpl into your working directory Tip Itis a good practice to save the configuration files into a directory other than the JProbe installation directory for example C JProbeFiles The Integration Wizard dialog box appears displaying the integration status In the Integrate tab click the browse button and navigate to the location where you want to save the startup script for example in Windows run_WithJProbe bat and in UNIX Linux systems run_WithJProbe sh then click Save Tip Itis a good practice to save the script files into a directory which is recommended by the integration Status dialog for example in this case the recommended path is C lt jboss_home gt bin directory When the integration is complete click Next The Run Configuration tab is displayed Select the Close syscon window on exit check box to automatically close the jpsyscon window after the termination of the launched script if the program exits normally To run your application with JProbe using the startup script click Run amp Connect Note To start JBoss using the startup script e In Windows C lt jboss_home gt bin run_WithJProbe bat e In a U
83. fference tool to compare snapshots To measure the performance improvement 1 In the JProbe Snapshot Navigator right click the minesweeper_normal snapshot and select Snapshot Differencing The Performance Difference dialog box appears The selected snapshot is displayed in the Snapshot to Compare field 2 Select minesweeper_methodtime from the Baseline Snapshot list and click OK If you isolated on different methods you see a message informing you that the snapshots have different transformations The isolate action among others is removed automatically to ensure that you are comparing the same data set The Performance Difference view opens By default only the classes with differences are displayed 3 To see the impact that changing the algorithm had on the servlet isolate the doGet method by typing doGet in the Filter Methods field The GameController doGet and GameImageServlet doGet methods are the only methods displayed A negative number in the Elapsed Cumulative Time column means an improvement The Normal mode offers a significant improvement over the Method Time mode This example demonstrates how in your own code an inefficient algorithm can significantly impact performance Of course you only want to optimize algorithms in the critical path of your program there is no point tuning algorithms that are called very rarely You also need to evaluate the overall impact on the runtime of the program If an ineffi
84. filters available for your application Select the My Application Filters check box 112 JProbe Tutorials All application filters are now selected and Action set to include JProbe can use these application filters as default data collection filters when performing a Memory analysis 8 Specify a Category Program Name then click Next 9 Inthe Analysis Type tab select Memory Analysis then click Next 10 Click Next again to pass the Advanced JProbe Options tab The Summary tab is displayed It presents a summary of the settings defined for your configuration 11 To create a JPL file and a startup script click Save amp Integrate 12 Click Save to save the configuration file LoiteringObjects_Mem_Settings jpl into your working directory Tip Itis a good practice to save the configuration files into a directory other than the JProbe installation directory for example C JProbeFiles The Integration Wizard dialog box appears displaying the integration status 13 In the Integrate tab click the browse button J and navigate to the location where you want to save the startup script for example in Windows run_WithJProbe bat and in UNIX Linux systems run_WithJProbe sh then click Save Tip Itis a good practice to save the script files into a directory which is recommended by the integration Status dialog for example in this case the recommended path is C lt jboss_home gt bin directory 14 When the integration i
85. ge collected if you free the removed edge from your application code Instance Eligible for Garbage Collection amp Congratulations the instance can be garbage collected Your next step is to free the removed edges in your application code Click OK The selected instance moves from the upper table to the lower one Your next step is to find the method that allocated the instance in order to understand why it is not being removed Close the Leak Doctor view by clicking the x on the tab In the Instance Detail view click the Trace tab to see the stack trace Select the LeakExample addButtonToPanel row right click and select Show Allocated At Source to examine the source code for this allocating method The Source view displays the LeakExample java source code The line that allocates the JBut ton is selected It is located within the addBut tonToPanel method Below this method is the method that is supposed to remove the buttons removeButtonFromPanel Memory Analysis Demos 25 LeakExample Tutorial welcome Runtime Summary instances Jel Instance Detail ify LeakExample java Line Source 77 public void addButtonToPanel a 78 if numButtons lt buttons length 79 JButton btn tt ring value0f numButt 81 buttons numButtons btn 82 removeButtonIndex mumRemoveButtons numButtons l 83 panel add btn 84 panel validate 85 panel repaint 86 y
86. ge the snapshots 1 Click Start gt Run and type the following then click OK e Ina Windows command window lt JPROBE_HOME gt bin jpcovmerge lt working_directory gt coverage_normal jpc lt working_directory gt coverage_loitering jpc lt working_directory gt coverage_merged jpc Ina UNIX or Linux shell lt JPROBE_HOME gt bin jpcovmerge lt working_directory gt coverage_normal jpc 94 JProbe Tutorials lt working_directory gt coverage_loitering jpc lt working_directory gt coverage_merged jpc Important This command fails if lt jprobe_home gt or lt working_directory gt has spaces in it You must quote the application arguments in this case On the JProbe Console click File gt Open Snapshot In the Open dialog box select lt working_directory gt coverage_merged jpc and click Open The merged snapshot is selected and its content is displayed in the Snapshot Browser view Step 6 Assessing Your Test Coverage After merging your test cases you are now ready to investigate your results By default JProbe displays results in terms of misses A miss means that the code was not called during your test cases To investigate your results 1 In the Snapshot Browser view expand the class tree in the upper pane to show all of the classes in demos gamepack minesweeper the game that was exercised Click the Missed Methods column heading in the upper pane to sort the table from hi
87. ge the snapshots using the jpcovmerge command line tool Before you can use this tool you must save to the disk the two snapshots to be compared To merge the snapshots 1 Save the snapshot taken during Step 3 Running the First Test Case to the disk a Right click the snapshot and select Save Snapshot As b Inthe Save As dialog box save the snapshot as lt working_directory gt first jpc Repeat step a to step b to save the snapshot taken during Step 4 Setting Up and Running the Second Test Case as lt working_directory gt second jpc Click Start gt Run and type the following then click OK e Ina Windows command window lt jprobe_home gt bin jpcovmerge lt working_directory gt first jpc 64 JProbe Tutorials lt working_directory gt second jpc lt working_directory gt merged jpc e Ina UNIX or Linux shell lt jprobe_home gt bin jpcovmerge lt working_directory gt first jpc lt working_directory gt second jpc lt working_directory gt merged jpc Important This command fails if lt jprobe_home gt or lt working_directory gt has spaces in it You must quote the application arguments in this case 4 On the JProbe Console click File gt Open Snapshot 5 In the Open dialog box select lt working_directory gt merged jpc and click Open The merged snapshot is selected and its content is displayed in the Snapshot Browser view Step 6 Assessing Your Test Case Coverage After merging your test cases you are now
88. ghest to lowest percentage of missed methods Methods are missed in several classes MineSweeperException MineSweeperModel MineSweeperScore MineSweeperSnapshot MineSweeperMove and MineSweeperRenderer We will investigate the first two classes In the upper pane select the MineSweeperModel class The methods for this class are displayed in the lower pane Select the play method right click and select Show Source to open the lt JPROBE_HOME gt demos gamepack src demos gamepack ninesweeper MineS weeperModel java source code The source code opens at a block of missed lines that are in an if statement so you know that the test case missed a condition Click the Down E button at the top of the coverage bar to the right of the scroll bar to move to the next set of missed lines JProbe Game Pack for JavaEE 95 Advanced Game Pack Evaluation 6 Continue in this way until you have examined all the missed blocks of code then move on to the next missed class Tip Once you identify an area for improvement you can modify the test suite and redo the tutorial to see the improvement in overall coverage Advanced Game Pack Evaluation This section describes how to deploy the JProbe Game Pack demo software on several third party application servers supported by JProbe and presents how to use JProbe with JavaEE applications that require these application servers For details see the following topics e Deploying the Game Pack Demo
89. gt is Geronimo s http port number The default value is 8080 The Game Pack startup welcome page appears You can now exercise the tutorials by clicking the available links For more information see Running Game Pack with the JProbe Application on page 109 Building and Deploying Game Pack on Geronimo If you want to make any changes in the Game Pack source files then you have to build a new Game Pack EAR file using the updated code and deploy the new EAR file instead To correctly build the Game Pack code with latest EJB 3 0 specification dependency libraries for JEE 1 5 the classpath J2EEServer property must contain paths to the following JAR files existing in the Geronimo installation directory geronimo ejb_3 0_spec 1 0 1 jar geronimo jpa_3 0_spec 1 1 1 jar geronimo jta_1 1_spec 1 1 1 jar geronimo servlet_2 5_spec 1 2 jar Alternatively you can set the classpath J2EEServer property to point to the Geronimo specs repository 100 JProbe Tutorials To build and deploy the Game Pack demo on Geronimo 1 In the lt JPROBE_HOME gt demos gamepack build directory edit the build properties file a Update classpath J2EEServer property with the paths to the following files lt GERONIMO_HOME gt repository org apache geronimo specs geron imo ejb_3 0_spec 1 0 1 geronimo ejb_3 0_spec 1 0 1 jar lt GERONIMO_HOME gt repository org apache geronimo specs geroni mo jpa_3 0_spec 1 1 1 geronimo jpa
90. h From Session F f The Instances view appears after a few seconds Note If a different snapshot is already opened in the JProbe Console the new snapshot taken does not open automatically To open it right click the snapshot name in the Snapshot navigator and select Open Snapshot 13 On the Game Pack demo page click Logout then close the browser Step 4 Identifying Loitering Objects In this step you look for loitering objects in the heap The Heap Count column is the first place to look In general you should expect objects created during a session to be removed at the end of it In fact the GameHandler objects are not removed and three instances of this object continue to loiter in the heap To identify loitering objects 1 Ifthe loitering_objects snapshot is not open right click it in the snapshot navigator and select Open Instances View The Instances view appears 2 In the Filter Classes field type GameHandler and press Enter to display only the GameHandler class The Heap Count for GameHandler is 3 not 0 zero as hypothesized Step 5 Investigating Loitering Objects In this step you find the live object that continues to hold a reference to the loitering instances of GameHandler in the heap You start in the Instances view then drill down to Instance Detail and the Memory Leak views and discover that the loitering JProbe Game Pack for JavaEE 115 Advanced Game Pack Evaluation GameHandler objects are being
91. he Application Arguments dialog box type fix in the upper field and click OK The argument appears in the Application Arguments field 7 To save the configuration file click Save 8 To integrate your application with JProbe click Integrate 9 In the Integration Wizard click Save to save the new startup script then click Next _ Oo Run the LeakExample startup script and connect JProbe click Run amp Connect 11 Follow the instructions in Step 2 Running the Memory Leak Session to exercise the same use case 12 13 14 Memory Analysis Demos 27 LeakExample Tutorial In the navigator right click the new snapshot with the improved code and select Snapshot Differencing The Memory Difference dialog box opens The new snapshot is displayed in the Snapshot to Compare list Select the original snapshot with the loitering objects from the Baseline Snapshot list Click OK The Memory Difference view appears displaying the differences in data between the two snapshots Use the filters to display only the JButton objects QWelcome Runtime Summary i Memory Difference 7 ym Baseline memoryleak_1 Other memoryleak_2 Percentage Size Change Recorded 89 15 Heap 37 73 Dead 7 27 Filter Classes 1 930 Name Recorded Count Heap Count j Recorded Memory Heap Memory Dead Count Dead Memory Total 268 12 949 10 904 716 904 398 28 016 javax swing JButton 10 10 4 640
92. hecking JPL file existence done Saving current settings in JPL file done Validating JPL file with jplauncher done Validating working directory done Generating startup scripttext done Please save JProbe startup script file to continue Updating permissions for the script file done Script file C JProbe workspacettutorials_jprobe_83 Polynomial bat amp JPL file C JProbe workspace ttutorials_83 Polynomial_Perf_Settings jp are generated successfully To launch your application with JProbe run this script from the command line Integration complete Press Next to open Run Configuration tab for executing JProbe startup script Close Wizard Cancel Help 21 When the integration is complete click Close Wizard You are now ready to run a Performance analysis session Step 2 Running the Polynomial Session In this step you exercise the use case on the Polynomial program All you need to do is to start the Polynomial program It runs to completion in about one minute depending on your system setup generating the data that you need to assess the performance of the nested loops algorithm To run the session 1 Inthe Configurations Navigator select Java Application gt Polynomial The Polynomial_Perf_Settings jpl tab appears in the View area 2 Click Run amp Connect JProbe is searching for currently running engines and JVMs after a few seconds the JProbe Console connects to the
93. his enables the recording of allocations traces and garbage collection on all instances In the Network Simulation program window click Start When the red lines disappear in the Network Simulation window the program has finished j on the toolbar Click Set Recording Level In the Set Recording Level dialog box select Data Recording Off then click OK JProbe takes a snapshot and displays it in the Snapshots Navigator In the Network Simulation window click Stop Close the Network Simulation window Memory Analysis Demos 31 Network Tutorial JProbe disconnects from the running session After a few seconds the Instances view appears displaying instances that were created during the session Note If a different snapshot is already opened in the JProbe Console the new snapshot taken does not open automatically To open it right click the snapshot name in the Snapshot navigator and select Open Snapshot Step 3 Identifying Large Allocations of Short Lived Objects The Heap Usage Chart indicates an excessive number of garbage collections To identify the short lived objects 1 Inthe Runtime Summary view click the Memory Pools tab The peaks and valleys in the Memory Pools graph show that the objects being collected are not alive very long before they are garbage collected Memory Pools Memory Pools 6 HEden Space survivor Space F HTenured Gen I Available A 0 00 02 30
94. iguration Type Java Application Edit Main Class demos performance polynomial Polynomial Edit Application Arguments N Edit Working Directory C Quest_Software JProbe_8 3 Edit Classpath C Quest_Software JProbe_8 3 Edit Java Executable C Quest_Software JProbe_8 3 bin jre bin java exe Edit Java Options Edit Category Program Name PolynomialDemo Edit Analysis Type performance Edit Advanced JProbe Options Edit JProbe Port 52991 Edit Snapshot Basename polynomial _ Edit JProbe Settings File 18 To create a JPL file and a startup script click Save amp Integrate 19 Click Save to save the configuration file Polynomial_Perf_Settings jpl into your working directory Tip Itis a good practice to save the configuration files into a directory other than the JProbe installation directory for example C JProbeFiles The Integration Wizard dialog box appears displaying the integration status 20 In the Integrate tab use the browse button to navigate to your working directory and click Save Tip Itis a good practice to save the script files into a directory other than the JProbe installation directory for example C JProbeFiles JProbe validates the configuration file and creates a startup script file for example in Windows Polynomial bat and in UNIX Linux systems Polynomial sh Performance Analysis Demos 51 Polynomial Tutorial Integration Wizard Integrate Integrating Polynomial Integration status C
95. in admin You are now ready to run a Coverage analysis session Step 3 Running the Session In this step you play the Minesweeper game in Normal mode three consecutive times test case 1 then three more times in Object Loitering mode test case 2 without quitting It does not matter for the analysis whether you win or lose the games For each test case you take a snapshot To run the session for a coverage analysis 1 Perform test case 1 92 JProbe Tutorials a Inthe Game Pack demo click Play beside Minesweeper b Select the Normal option Note Clicking the link displays the option s definition c Click Start and play the game d When the game ends play the game twice more without quitting for a total of three complete games e Click Quit f Inthe JProbe Console click Take Snapshot c on the toolbar JProbe takes a snapshot and displays it in the Snapshots Navigator g Inthe Snapshots Navigator right click the snapshot select Save Snapshot As and navigate to where you want to save the snapshot h Name the snapshot coverage_normal and click Save The snapshot name is displayed in the Snapshots Navigator Perform test case 2 a Inthe Game Pack demo click Play beside Minesweeper b Select the Loitering Object option Note Clicking the link displays the option s definition c Click Start and play the game d When the game ends play the game twice more without quitting for a total of three complete ga
96. intelligent code performance analysis and problem resolution from within the Eclipse Java IDE About This Guide The JProbe Tutorials contains a summary of all the demo applications that ship with JProbe It also contains tutorials for some of these applications This document is intended for Java developers who want to learn how to configure JProbe to work with their application and run a JProbe analysis The JProbe Tutorials is organized as follows Chapter 1 Memory Analysis Demos provides a summary of the Memory demo applications that ship with JProbe and contains tutorials for some of these applications Chapter 2 Performance Analysis Demos provides a summary of the Performance demo applications that ship with JProbe and contains tutorials for some of these applications Chapter 3 Coverage Analysis Demos provides a summary of the Coverage demo applications that ship with JProbe and a tutorial for one of these applications Chapter 4 JProbe Game Pack for JavaEE describes how to deploy the JProbe Game Pack demo software and presents how to use JProbe with JavaEE applications Introduction to This Guide 9 JProbe Documentation Suite that require a third party application server The Game Pack tutorials describe how to find two different kinds of memory leaks with the Memory analysis tool how to investigate a performance bottleneck with the Performance analysis tool and how to assess code coverage with the Coverage analy
97. ion test case 1 Step 3 Running the First Test Case To run the first test case To run your application startup script and also connect the JProbe Console select Demo Adventure Coverage Analysis in the Configurations tab and click Run amp Connect in the View area The JProbe Execution Console opens and the program runs using the text file AdvTest1 txt as test case input for choices When the program is finished the command window closes JProbe takes a coverage snapshot and displays it in the Snapshots Navigator and in the Snapshot Browser view Note If a different snapshot is already opened in the JProbe Console the new snapshot taken does not open automatically To open it right click the snapshot name in the Snapshots Navigator and select Open Snapshot welcome 9 Coverage Session Bj Snapshot Browser 7 aq Missed Classes Missed Methods Missed Lines With Line Data Exiga amp demos coverage adventure Show Only Methods with Missed li gt Method Method Missed Missed Lines Missed Lines Total Lines 100 0 8 g 2 demos coverage adventure Adventure main java lang String J No 50 0 a 7 14 demos coverage adventure Kitchen lt init gt Yes 100 0 M 7 7 demos coverage adventure Logic lt init gt demos coverage adventure RoomlList Yes 100 0 ME 7 a demos coverage adventure Adventure cleanup Yes 100
98. is important that you start a use case before you begin to play or JProbe will not perform a garbage collection After you have played three games you end the use case and JProbe takes a snapshot To run a game with the Object Cycling fault 1 In the Game Pack demo select Play beside Match Game 2 Select the Object Cycling option Note Clicking the link displays the option s definition 3 In the JProbe Runtime Summary view click Set Recording Level toolbar 80 JProbe Tutorials 10 11 12 13 Step 4 In the Set Recording Level dialog box select Record Allocations Stack Traces and Garbage Data For All Instances and click OK In the Game Pack demo click Start and play the game When the game ends play the game twice more without quitting for a total of three complete games Click Quit In the Runtime Summary view click Set Recording Level on the toolbar In the Set Recording Level dialog box select Data Recording Off then click OK JProbe takes a snapshot and displays it in the Snapshots Navigator In the Snapshots Navigator right click this snapshot select Save Snapshot As and navigate to where you want to save the snapshot Name the snapshot object_cycling and click Save The snapshot name is displayed in the Snapshots Navigator Click Detach From Session F The Instances view appears after a few seconds Note If a different snapshot is already opened in the JProbe Consol
99. ith Improved Code Step 5 Measuring the Performance Improvement Step 1 Setting Up the Polynomial Session To collect timing data on the original algorithm you need to set up the session in the JProbe Console The following procedures mention only the settings that you need to change or verify If a setting is not mentioned leave it blank or in its default state The procedure assumes that you are running JProbe locally on your computer To set up the session 1 In the JProbe Console click Configurations gt New Configuration The New Configuration Wizard dialog box appears Click Java Application gt Java Application Provide a name for this configuration in the Configuration Name text box for example Polynomial then click Next The Java Application tab is displayed In the Main Class area select the Execute a class check box Click the browse button in the Main Class area and navigate to the Polynomial class file in the lt jprobe_home gt demos performance polynomial directory Click OK The following information is displayed e Main Class demos performance polynomial Polynomial e Working Directory lt jprobe_home gt To use the nested loop algorithm you need to enter a program argument a Click the browse button beside the Application Arguments field b In the upper field of the Application Arguments dialog type N 17 Performance Analysis Demos 49 Polynomial Tutorial c Click Parse Arguments The a
100. java 211 a demos memory sim Sim rung 80 000 Sim java 413 java lang Thread rund 80 000 Not Available 3 Select Sim Server query right click and select Show Allocated At Source The Source view opens displaying the Sim java source code at the line indicated in the Source column 211 Line Source new Connection 212 213 214 Result result new Result 215 connect queryilogin password request result 216 connect release 217 218 if Sim this fixCommection 219 cache freeConnection id 220 221 222 return result 223 224 v Notice that each time a client sends a query to the server the server creates a new connection to the database that lasts until the connection is terminated Also notice that Connection is an inner class of Sim 4 Inthe Merged Allocation Points view lower pane select Sim Client start right click and select Show Allocated At Source The Source view opens displaying the Sim java source code at the line indicated in the Source column 286 Line Source 282 if Sim this fixLogin a 283 result server query primaryKey 5 login pswd 284 query 285 else 5 my login primaryKey my_password SELECT customer FROM sales WHERE location E primaryKey AND product product 291 I lt 34 JProbe Tutorials Notice that each time a client sends a query to the server String objects are concatenated This is
101. ject problem 2 Select the Loitering Objects option Note Clicking the link displays the option s definition 3 In the JProbe Runtime Summary view click Set Recording Level on the toolbar 74 JProbe Tutorials 10 11 12 13 Step 4 In the Set Recording Level dialog box select Record Allocations and Stack Traces For All Instances then click OK In the Game Pack demo click Start and play the game When the game ends play the game twice more without quitting for a total of three complete games Click Quit In the Runtime Summary view click Set Recording Level on the toolbar In the Set Recording Level dialog box select Data Recording Off then click OK JProbe takes a snapshot and displays it in the Snapshots Navigator In the Snapshots Navigator right click the snapshot select Save Snapshot As and navigate to where you want to save the snapshot Name the snapshot loitering_objects and click Save The snapshot name is displayed in the Snapshots Navigator Click Detach From Session F The Instances view appears after a few seconds Note If a different snapshot is already opened in the JProbe Console the new snapshot taken does not open automatically To open it right click the snapshot name in the Snapshot navigator and select Open Snapshot On the Game Pack demo page click Logout then close the browser Shutting Down the Server In this step you close the Geronimo Tom
102. k 1 In the Summary view select the top method suggested for investigation java awt MediaTracker waitForID int in the Performance Hotspot section right click and select Investigate The Methods view appears Select Hot Methods Elapsed Time from the Color to Show list Tip You can change the default Red Gray color scheme Right click the color scale located between the graph and the list and select a different color scheme JProbe Game Pack for JavaEE 127 Advanced Game Pack Evaluation 3 In the Call Graph identify the critical node In this example it is the last node on the right side MediaTracker waitForID 4 Hover over the MediaTracker waitForID node to display its tooltip You can see that the Elapsed Method Time is 495 ms and it is called 600 times Note The actual number for time and calls for the function waitForID can vary depending upon how many times the minesweeper image is being displayed Conclusion The performance bottleneck is caused by the Game Pack method renderMineMapImage_MethodTime calling these expensive third party methods for every tile in the game board Step 5 Running the Session with Improved Code After you discover the performance bottleneck you can choose how best to fix your code Review the source code You could attempt to call a less expensive method or you might choose an entirely new algorithm to do the same task For the Game Pack demo we decided to use a different way to
103. lect Show Allocated At Source If you are prompted for the source code navigate to lt jprobe_home gt demos gamepack src demos gamepack web game select EJBControllerImpl java and click Open The Source view opens highlighting line 174 of the code This line represents the method call from the getGameHandlerRemote method to the application server s create method which creates the beans Now that you found the method that creates the loitering GameHandler objects you are close to finding out where the objects should be removed Scrolling down to line 185 you find that the resetGameHandlerRemote method is the problem method When the Loitering Objects mode is selected the _gameHandlerRemote removeObject method is not called so the references to the GameHandler objects are never removed Tip It is good programming practice to pair your calls to create and remove objects close together Step 7 Running the Session with Improved Code You can re run Minesweeper or Match Game in Normal mode with the corrected code Repeat Step 1 Starting the Session and the Game Pack through Step 4 Shutting Down the Server selecting Normal mode instead of Loitering Objects and not re naming the snapshot You will see in the Instances view that the Heap Count for GameHandler is now 0 as predicted by the hypothesis JProbe Game Pack for JavaEE 77 Quick Game Pack Evaluation This example demonstrates how to use JProbe to identify a
104. lect the No check box Note Alternatively for customizing different configuration options such as listen ports select the Yes check box This adds several steps to the configuration process 10 _ JProbe Game Pack for JavaEE 105 Advanced Game Pack Evaluation Specify the directory where the WebLogic domain will be created The default is in the user_projects domain directory of your WL_HOME The default domain name is gamepack You can leave the default directory or change it Specify the directory where WebLogic Applications will be stored The default is the user_projects applications directory of your WL_HOME You can leave the default directory or change it Click Create to create the domain in the selected directory When the configuration is created click Done Start the Game Pack using your new configuration by executing the startWebLogic cmd command from the WL_HOME user_projects domains gamepack directory or other directory if you made changes in the Configuration Wizard To view the Game Pack open a browser and type http localhost lt port gt gamepack where lt port gt is WebLogic s http port number The default value is 7001 The Game Pack startup welcome page appears You can now exercise the tutorials by clicking the available links For more information see Running Game Pack with the JProbe Application on page 109 You can now stop WebLogic by using the stopWebLogic cmd command from the W
105. llocated by renderGameMap_StringConcatenation renderGamePlay_StringConcatenation and renderSnapshot_StringConcatenation methods in the MatchGameRenderer class demos gamepack matchgame package Step 5 Investigating Object Cycling In Java the JVM converts string concatenations into StringBuffer objects which means that each concatenation creates a new object with a very short life span This is a less efficient way to handle strings Take a look at the source code to see exactly how the application works The _StringConcatenation methods are in the MatchGameRenderer java source code You can use any editor to examine the allocating methods but it makes it easier to find the method if your editor has a search feature Remember that in this case the code contains the fixed code as well To investigate the garbage collected objects 1 Navigate to lt jprobe_home gt demos gamepack src demos gamepack matchgame and open the MatchGameRenderer java file in a source code editor 2 Search for the top method renderGamePlay_StringConcatenation 3 Observe that the method contains many string concatenations If you scroll down to find renderSnapshot_StringConcatenation and then renderGameMap_StringConcatenation you can see that these methods also use string concatenation Step 6 Running the Session with Improved Code The file MatchGameRendererjava also contains methods that offer a better way to handle the strings While you have the sou
106. me ends play the game twice more without quitting for a total of three complete games Click Quit In the JProbe Console click Take Snapshot a on the toolbar JProbe takes a snapshot and displays it in the Snapshots Navigator In the Snapshots Navigator right click the snapshot select Save Snapshot As and navigate to where you want to save the snapshot Name the snapshot coverage_normal and click Save The snapshot name is displayed in the Snapshots Navigator Perform test case 2 In the Game Pack demo click Play beside Minesweeper Select the Loitering Object option Note Clicking the link displays the option s definition Click Start and play the game When the game ends play the game twice more without quitting for a total of three complete games Click Quit In the JProbe Console click Take Snapshot a on the toolbar JProbe takes a snapshot and displays it in the Snapshots Navigator In the Snapshots Navigator right click the snapshot select Save Snapshot As and navigate to where you want to save the snapshot Name the snapshot coverage_loitering and click Save The snapshot name is displayed in the Snapshots Navigator Click Detach From Session F The Snapshot Browser view appears after a few seconds 4 Close the Coverage Session and the Snapshot Browser views 5 On the Game Pack demo page click Logout then close the browser JProbe Game Pack for JavaEE 133 Advanced Game Pack Evalua
107. ments for your configuration Because these are tests that may be modified and re run do this by creating a second configuration based on the original by copying and editing it To set 1 7 up and run the second test case In the Configurations Navigator right click Demo Adventure Coverage Analysis and select Copy settings for Coverage Analysis The settings are copied from the original configuration into Demo Adventure Coverage Analysis 1 the new configuration appears in the Configurations Navigator Select Demo Adventure Coverage Analysis 1 in the Configurations Navigator The Configuration Details tab is displayed in the View area Click Edit In the Configuration Name text box type Adventure_TestCase2 as the name for the new configuration Click the Java Application tab to change the program argument a Click the browse button beside the Application Arguments field b Inthe Application Arguments dialog box select the existing argument in the lower box and click Delete c Edit the argument in the upper box as follows lt jprobe_home gt demos coverage adventure AdvTest2 txt Note _ If there is a space in your JProbe home directory path enclose the argument in quotes d Click Parse Argument The argument appears in the first line of the lower field e Click OK The Application Arguments field displays the program argument Click Save then Save As to save the configuration file Adventure_TestCase2_Cov_Se
108. mes e Click Quit f Inthe JProbe Console click Take Snapshot a on the toolbar JProbe takes a snapshot and displays it in the Snapshots Navigator g Inthe Snapshots Navigator right click the snapshot select Save Snapshot As and navigate to where you want to save the snapshot h Name the snapshot coverage_loitering and click Save The snapshot name is displayed in the Snapshots Navigator Click Detach From Session F The Snapshot Browser view appears after a few seconds JProbe Game Pack for JavaEE 93 Quick Game Pack Evaluation 4 Close the Coverage Session and the Snapshot Browser views 5 On the Game Pack demo page click Logout then close the browser Step 4 Shutting Down the Server In this step you close the Geronimo Tomcat application server To stop the Geronimo Tomcat server 1 Open a command window and navigate to lt JPROBE_HOME gt demos settings Type in the following command e In Windows startWith_CovAnalysis bat stop e Ina UNIX or Linux shell startWith_CovAnalysis sh stop Type in Username system Type in Password manager The Geronimo Tomcat application server shuts down and the JProbe Execution Console closes Step 5 Merging the Test Results In this step you merge the snapshots taken during Step 3 Running the Session to get a complete picture of the coverage provided by these two test cases You merge the snapshots using the jpcovmerge command line tool To mer
109. nd remove loitering objects from your code Object Cycling Tutorial The Match Game offers an Object Cycling mode The Object Cycling mode demonstrates how over allocating short lived objects can cause the garbage collector to run more frequently than necessary Garbage collection takes time and resources The Normal mode shows that it is often more efficient to reuse strings The following table summarizes the types of information you need to know before starting this tutorial Program Game Pack Demo Match Game Use Case Play three games without quitting Architecture Object Cycling Use string concatenation Normal Append to an existing string buffer object Hypothesis The program does not create unnecessary temporary string objects The tutorial walks you through the following steps e Step 1 Starting the Session and the Game Pack e Step 2 Logging in to Game Pack e Step 3 Running the Session e Step 4 Shutting Down the Server e Step 5 Identifying Object Cycling e Step 6 Investigating Object Cycling e Step 7 Running the Session with Improved Code Step 1 Starting the Session and the Game Pack In this step you start the Geronimo Tomcat server using the pre defined startup script shipped with JProbe then connect JProbe to the Game Pack application running on this server 78 JProbe Tutorials To start the session from command line 1 To sta 1 Type in the following command depending on your platform
110. nd start the Game Pack 1 On the JProbe Console click Configurations gt New Configuration The New Configuration Wizard dialog box appears Click JBoss gt JBoss v5 x Provide a name for this configuration in the Configuration Name text box for example PerformanceBottleneck then click Next Type the path to your server startup script in the text field or click the browse button g and navigate to it then click Next In the My Code tab in the Elements area type the path to the deployed gamepack ear file for example lt jprobe_home gt demos gamepack 124 JProbe Tutorials support deployment JBoss WithTomcat gamepack ear or click the browse button J and navigate to it 6 Click Create Filters The table is populated with the filters available for your application 7 Select the My Application Filters check box All application filters are now selected and Action set to include JProbe can use these application filters as default data collection filters when performing a Performance analysis 8 Specify a Category Program Name then click Next 9 Inthe Analysis Type tab select Performance Analysis 10 In the Filters tab ensure that all collection filters are selected and set Action to line for each of them then click Next 11 Click Next again to pass the Advanced JProbe Options tab The Summary tab is displayed It presents a summary of the settings defined for your configuration 12 To create a JPL file an
111. ne window and the Welcome to the JProbe Game Pack Demo Application page opens in a Web browser Note If the Web browser does not open the welcome page you can open a browser and type http localhost 8686 gamepack The default value of the pre configured Geronimo HTTP port is 8686 The Game Pack welcome startup page appears Open the JProbe Console and click Attach to Session In the Attach to Session dialog box select the JProbe Analysis Engine and click OK JProbe connects to the Game Pack application and the Runtime Summary view opens in the Console To start the session from the JProbe Console 1 Click the Configurations tab and expand Apache You can see that JProbe includes a pre defined configuration file for the Game Pack memory demos Click Demo Gamepack Memory Analysis The Gamepack_Mem_Settings jpl tab is displayed in the View area Click through the configuration tabs to review the settings Note These pre defined settings cannot be modified or deleted You do not need to integrate your application with JProbe because a startup script is already provided for this demo To run the Game Pack startup script and also connect the JProbe Console click Run amp Connect JProbe Game Pack for JavaEE 73 Quick Game Pack Evaluation The JProbe Execution Console opens the Geronimo Tomcat application server and the Game Pack application start and the Welcome to the JProbe Game Pack Demo Application page opens in a
112. nect The JProbe Execution Console opens then the Network Simulation program starts displaying a window with icons representing elements of a network You are now ready to run a Memory analysis session Network Simulation DER 30 JProbe Tutorials Step 2 Running the Network Session In this step you exercise the use case on the Network Simulation program All you need to do is to click the Start button in the Network Simulation program the program simulates clients threads connecting to a server and querying a database It runs to completion in about one minute depending on your system setup generating the data that you need to assess the performance of the garbage collector Note This procedure assumes that the Network Simulation program is already running for instructions on how to execute the startup script see step 5 in section Step 1 Setting Up the Network Session on page 29 Alternatively you can run the startup script from the command line In a Windows command window Network bat In a UNIX or Linux shell from the directory where you saved the startup script Network sh To run the session 1 In the JProbe Console on Runtime Summary view select Five Minutes from the Pools and GC Interval list H f on the toolbar Click Set Recording Level In the Set Recording Level dialog box select Record Allocations Stack Traces and Garbage Data For All Instances then click OK T
113. ng browsers e FireFox e Microsoft IE e Apple Safari e Jakarta Ant 1 6 3 or later For a list of JProbe supported platforms and installation instructions see the JProbe Installation Guide The guide is available as a PDF file on the DVD and in the JProbe installation directory lt jprobe_install gt doc You can download Ant 1 6 3 or later from the Apache Jakarta Project at http jakarta apache org ant Extract the files to a directory Setting Environment Variables Before you begin set up the following environment variables e ANT _HOME lt ant_install_dir gt JPROBE_HOME lt jprobe_install_dir gt 70 JProbe Tutorials e If you are using Geronimo GERONIMO_HOM E lt geronimo_install_dir gt e If you are using JBoss JBOSS_HOME lt jboss_install_dir gt e Ifyou are using WebLogic Server Wh_HOME lt wlserver _install_dir gt Add the following paths to your PATH environment variable use the syntax appropriate for your operating system e SANT_HOME bin SJPROBE_HOMES e If you are using Geronimo 3GERONIMO_HOME e If you are using JBoss 3JBOSS_HOME e Ifyou are using WebLogic Server 3wL_HOME Quick Game Pack Evaluation In order to make easier the evaluation of the Game oe Pack demo JProbe includes a Geronimo Tomcat 2 1 application server pre configured and integrated with the Game Pack application Note If you want to run the Game Pack demo with an application server
114. nks For more information see Running Game Pack with the JProbe Application on page 109 You can now stop WebLogic by using the stopWebLogic cmd command from the WL_HOME user_projects domains gamepack bin directory or other directory if you made changes in the Configuration Wizard and prepare to run the Game Pack in JProbe Building and Deploying Game Pack on Oracle WebLogic Server 11g If you want to make any changes in the Game Pack source files then you have to build a new Game Pack EAR file using the update instead To correctly build the Game Pack code with libraries for JEE server the classpath J21 d code and deploy the new EAR file latest EJB 3 0 specification dependency EEServer property must contain paths to the following JAR files existing in the Oracle WebLogic Server 11g installation directory e api jar e javax persistence_1 0 0 0_1 0 2 jar JProbe Game Pack for JavaEE 109 Advanced Game Pack Evaluation Alternatively you can copy the WebLogic Java EE 5 libraries javax persistence_1 0 0 0_1 0 2 jar and api jar in lt JBPROBE_HOME gt gamepack lib directory no property setting is required in this case To build and deploy the Game Pack demo on Oracle WebLogic Server 11g 1 In the lt JPROBE_HOME gt demos gamepack build directory edit the build properties file a Update classpath J2EEServer property with the paths to the following files lt WLS_HOME gt wlserver_10 3
115. o because you removed all the buttons you added In fact the buttons are not removed and continue to loiter in the heap To identify loitering objects 1 Inthe Instances view select Heap Count from the Investigate by list 2 Type JButton in the Filter Classes field and press Enter to locate the JButton class Note This field is case sensitive The Instances list now displays only the JButton class 22 JProbe Tutorials Filter Classes ENE x 1 930 Name Recorded Count Heap Count Recorded Memory Heap Memory Keep Alive Size Dead Count Dead Memory Total 295 29 036 12 232 1 905 728 1 905 728 8 889 385 584 javax swing JButton 10 12 4 640 5 568 12 512 0 o The Recorded Count for JButton is 10 and the Dead Count is 0 This means that the buttons were removed from the Leak Example program window but not from the Java heap Step 4 Investigating Loitering Objects In this step you find the live object that continues to hold a reference to the loitering instances of JButton From the Instances view you can drill down to more detail on JButton in the Instance Detail view Then you can open the Source view to see the code for the loiterer You will find that the loitering JButton objects are being held by obsolete collection references from the array JButton To investigate loitering objects 1 In the Instances view select the JButton row and click Instance Detail on the toolbar The
116. obe sh JProbe Execution Console opens and the application server and the Game Pack application start JProbe connects to the Game Pack application and the Runtime Summary view opens in the Console Step 2 Logging in to Game Pack In this step you log in to the Game Pack demo 1 Open a Web browser and go to http ocalhost 8080 gamepack The Game Pack Demo login page appears 2 Enter your User ID and Password then click Login Note The first time you do this you need to create a user name and password for yourself For more information see Creating a User Account for Game Pack on page 134 Alternatively you can use the default user ID password admin admin You are now ready to run a Performance analysis session Step 3 Running the Session In this step you exercise the use case by selecting one tile It does not matter for the analysis whether the tile reveals a number or a mine In Method Time mode the entire game board is redrawn on the server side encoded and sent to the browser You should find that the game responds slowly To run a game with a performance bottleneck 1 In the Game Pack click Play beside Minesweeper 2 Select the Method Time option Note Clicking the link displays the option s definition 3 In the JProbe Runtime Summary view click Set Recording Level on the toolbar 4 Inthe Set Recording Level dialog box set the slider to select Full Encapsulation and click OK 126 JProbe T
117. opment Mode check box Select a JDK from the available list default is recommended then click Next The Configure JDBC Data Sources page appears displaying the Game Pack data source name with host or user name information Do not select anything in the Data Source table in the Configure JDBC Data Sources page Click Next without modifying any setting The Configuring Data Source dialog box appears After a few seconds the following error message is displayed CFGFWK 60850 Test Failed 108 JProbe Tutorials 12 Click Next without modifying any settings A warning dialog box appears displaying the following message Click Cancel and select Data Sources to test or Click OK to bypass testing 13 Click OK 14 In the Select Optional Configuration p Next age review the default settings and click 15 Click Create to create the domain in the selected directory 16 When the configuration is created click Done 17 Start the Game Pack using your new configuration by executing the startWebLogic cmd command from the WL_HOME user_projects domains gamepack directory or other directory if you made changes in the Configuration Wizard 18 To view the Game Pack open a brows er and type http localhost lt port gt gamepack where lt port gt is WebLogic s http port number The default value is 7001 The Game Pack startup welcome page appears You can now exercise the tutorials by clicking the available li
118. other than Geronimo Tomcat 2 1 you need to deploy Game Pack on that application server before running a memory performance or coverage analysis For Evaluation on page 95 details see Advanced Game Pack The JProbe installer sets up the Geronimo application server and Game Pack in the lt JPROBE_HOME gt demos gamepack directory installs three ready to use JPL settings files and creates three Geronimo Game Pack confi gurations one for each analysis type These pre defined configurations are available in the Configurations Navigator and you just need to run them in order to start a memory performance or coverage analysis For details see the following topics e Game Pack Memory Analysis Tutorials on page 71 e Game Pack Performance Analysis Tutorial on page 83 e Game Pack Coverage Analysis Tutorial on page 89 JProbe Game Pack for JavaEE 71 Quick Game Pack Evaluation Game Pack Memory Analysis Tutorials The Game Pack Memory tutorials describe how to find two different kinds of memory leaks using the JProbe Memory analysis tool and the pre defined Demo Gamepack Memory Analysis configuration e Loitering Objects Tutorial on page 71 e Object Cycling Tutorial on page 77 Loitering Objects Tutorial Minesweeper and the Match Game both offer a Loitering Objects mode The Loitering Objects mode demonstrates how an obsolete container reference can keep session beans in the Jav
119. ou can use any editor to examine the allocating methods but it makes it easier to find the method if your editor has a search feature Remember that in this case the code contains the fixed code as well To investigate the garbage collected objects 1 Navigate to lt jprobe_home gt demos gamepack src demos gamepack matchgame and open the MatchGameRenderer java file in a source code editor 2 Search for the top method renderGamePlay_StringConcatenation 3 Observe that the method contains many string concatenations If you scroll down to find renderSnapshot_StringConcatenation and then renderGameMap_StringConcatenation you can see that these methods also use string concatenation Step 7 Running the Session with Improved Code The file MatchGameRenderer java also contains methods that offer a better way to handle the strings While you have the source code open you can scroll to find these improved methods e renderGamePlay_StringBufferAppend e renderSnapshot_StringBufferAppend e renderGameMap_StringBufferAppend If you want you can re run this tutorial using Normal mode which uses the improved methods When you check the Instances view you should see that the number of short lived StringBuffer objects is reduced significantly This example demonstrates how to use JProbe to identify and remove object cycling problems in your code JProbe Game Pack for JavaEE 83 Quick Game Pack Evaluation Game Pack Performance Analysis Tutori
120. ou do this you need to create a user name and password for yourself For more information see Creating a User Account for Game Pack on page 134 Alternatively you can use the default user ID password admin admin You are now ready to run a Performance analysis session Step 3 Running the Session In this step you exercise the use case by selecting one tile It does not matter for the analysis whether the tile reveals a number or a mine In Method Time mode the entire game board is redrawn on the server side encoded and sent to the browser You should find that the game responds slowly To run a game with a performance bottleneck 1 2 In the Game Pack click Play beside Minesweeper Select the Method Time option Note Clicking the link displays the option s definition In the JProbe Runtime Summary view click Set Recording Level on the toolbar 86 JProbe Tutorials 10 11 12 Step 4 In the Set Recording Level dialog box set the slider to select Full Encapsulation and click OK In the Game Pack click Start and click on several tiles until you are blocked Click Quit In the Runtime Summary view click Set Recording Level on the toolbar In the Set Recording Level dialog box set the slider to select Data Recording Off then click OK JProbe takes a snapshot and displays it in the Snapshots Navigator In the Snapshots Navigator right click this snapshot select Save Snapshot As
121. overage Starting the Session and the Game Pack In this step you start the Geronimo Tomcat server using the pre defined startup script shipped with JProbe then connect JProbe to the Game Pack application running on this Server To start the session from command line 1 Type in the following command depending on your platform In Windows lt JPROBE_HOME gt demos settings startWith_CovAnalysis bat In a UNIX or Linux shell lt JPROBE_HOME gt demos settings startWith_CovAnalysis sh The Geronimo Tomcat application server and the Game Pack application start in a command line window and the Welcome to the JProbe Game Pack Demo Application page opens in a Web browser Note If the Web browser does not open the welcome page you can open a browser and type http localhost 8686 gamepack The default value of the pre configured Geronimo HTTP port is 8686 The Game Pack welcome startup page appears Open the JProbe Console and click Attach to Session In the Attach to Session dialog box select the JProbe Analysis Engine and click OK JProbe connects to the Game Pack application and the Runtime Summary view opens in the Console To start the session from the JProbe Console 1 Click the Configurations tab and expand Apache You can see that JProbe includes a pre defined configuration file for the Game Pack coverage demo JProbe Game Pack for JavaEE 91 Quick Game Pack Evaluation 2 Click Demo Gamepack Coverag
122. p procedure only the settings that you need to change or verify are mentioned If a setting is not mentioned leave it blank or in its default state The following procedure assumes that you are running JProbe locally on your computer To set up the session and start the Game Pack 1 On the JProbe Console click Configurations gt New Configuration The New Configuration Wizard dialog box appears 2 Click JBoss gt JBoss v5 x 3 Provide a name for this configuration in the Configuration Name text box for example CoverageLoitering then click Next 130 JProbe Tutorials 10 11 12 13 14 Type the path to your server startup script in the text field or click the browse button and navigate to it then click Next In the My Code tab in the Elements area type the path to the deployed gamepack ear file for example lt jprobe_home gt demos gamepack support deployment JBoss WithTomcat gamepack ear or click the browse button and navigate to it Click Create Filters The table is populated with the filters available for your application Select the My Application Filters check box All application filters are now selected and Action set to include JProbe can use these application filters as default data collection filters when performing a Memory analysis Specify a Category Program Name then click Next In the Analysis Type tab select Coverage Analysis Click Next again to pass the Advanced JProbe Options
123. pack For JBoss http Nocalhost 8080 gamepack For WebLogic Server http ocalhost 7001 gamepack 6 Exercise the use case Game Pack Memory Analysis Tutorials The Game Pack Memory tutorials describe how to find two different kinds of memory leaks using the JProbe Memory analysis tool e Loitering Objects Tutorial on page 110 e Object Cycling Tutorial on page 116 Loitering Objects Tutorial Minesweeper and the Match Game both offer a Loitering Objects mode The Loitering Objects mode demonstrates how an obsolete container reference can keep session beans in the Java heap long after their usefulness is gone In this tutorial you see how you can reclaim memory by removing loitering GameHandler objects Before beginning this tutorial you need to deploy the Game Pack to the application server of your choice For more information see Deploying the Game Pack Demo on Your Application Server on page 95 Note The values cited in this tutorial reflect the Game Pack running on the JBoss 5 1 0 application server on Windows XP The following table summarizes the types of information you need to know before starting this tutorial Program Game Pack demo Match Game Use Case Play a few games without quitting Architecture When the Start button is selected create a GameHandler object to run the game JProbe Game Pack for JavaEE 111 Advanced Game Pack Evaluation Hypothesis The GameHandler object is removed from
124. rce code open you can scroll to find these improved methods e renderGamePlay_StringBufferAppend e renderSnapshot_StringBufferAppend 122 JProbe Tutorials e renderGameMap_StringBufferAppend If you want you can re run this tutorial using Normal mode which uses the improved methods When you check the Instances view you should see that the number of short lived StringBuffer objects is reduced significantly This example demonstrates how to use JProbe to identify and remove object cycling problems in your code Game Pack Performance Analysis Tutorial The Game Pack Performance tutorial Performance Bottleneck Tutorial describes how to investigate a performance bottleneck using the JProbe Performance analysis tool Performance Bottleneck Tutorial The Minesweeper game can be played in the Method Time mode This mode demonstrates a performance bottleneck caused by an inappropriate algorithm that is used for rendering the Minesweeper game board as one large image For comparison you can play the game in the Normal mode which creates the game board as a table containing HTML links to images Before beginning this tutorial you need to deploy the Game Pack to the application server of your choice For more information see Deploying the Game Pack Demo on Your Application Server on page 95 Note The values cited in this tutorial reflect the Game Pack running on the JBoss 5 1 0 application server on Windows XP Th
125. rgument appears in the first line of the lower field d Click OK The Application Arguments field displays the program argument Click the browse button beside the Classpath field In the Classpath dialog box click Add Working Directory then click OK The working directory appears in the Classpath field Click Next The Select a Java Virtual Machine tab is displayed If you want to change the default JVM click the browse button beside the Java Executable field select another JVM in the Java Virtual Machines dialog box and click OK Note Ideally the JVM you choose should be the version that was used to compile your program Click Next The My Code tab is displayed In the Category Program Name text box type PolynomialDemo which specifies the name of the category in which you want to include your code then click Next The Analysis Type tab is displayed Select the Performance Analysis option On the General tab select the CPU timing option On the Automation tab move the slider to select the Full Encapsulation option then click Next This enables JProbe to collect data for all methods and the methods they call from the initial JVM start The Advanced JProbe Options tab is displayed In the Snapshot Basename text box type polynomial_ and then click Next The Summary tab is displayed It presents a summary of the settings defined for your configuration 50 JProbe Tutorials Configuration Name Polynomial Edit Conf
126. rithm To quantify the improvement use the Snapshot Difference tool to compare snapshots To measure the performance improvement 1 Inthe JProbe Snapshots Navigator right click the minesweeper_normal snapshot and select Snapshot Differencing The Performance Difference dialog box appears The selected snapshot is displayed in the Snapshot to Compare field 2 Select minesweeper_methodtime from the Baseline Snapshot list and click OK If you isolated on different methods you see a message informing you that the snapshots have different transformations The isolate action among others is removed automatically to ensure that you are comparing the same data set JProbe Game Pack for JavaEE 89 Quick Game Pack Evaluation The Performance Difference view opens By default only the classes with differences are displayed 3 To see the impact that changing the algorithm had on the servlet isolate the doGet method by typing doGet in the Filter Methods field The GameController doGet and GameImageServlet doGet methods are the only methods displayed A negative number in the Elapsed Cumulative Time column means an improvement The Normal mode offers a significant improvement over the Method Time mode This example demonstrates how in your own code an inefficient algorithm can significantly impact performance Of course you only want to optimize algorithms in the critical path of your program there is no point tuning algorithms th
127. rmance P mcoverage Source Files 4 Click OK Show Bar Chart for Percentage Metrics V Filter out Catch Blocks Filtered Catch Block Color E Change Metric Colors Runtime Hit E Change Missed Lines i change _ Missed Conditions change _ No Data for Line change Step 2 Setting Up the Session for the First Test Case In this step you create a configuration for the Adventure program using the JProbe Console The configuration includes the path to a text file that contains the first test case To set up the first test case 1 Inthe JProbe Console click the Configurations tab 2 Expand Java Application You can see that JProbe includes a pre defined configuration file for the Adventure demo 3 Click Demo Adventure Coverage Analysis The Adventure_Cov_Settings jpl tab is displayed in the View area 4 Click through the configuration tabs to review the settings In the Java Application tab you can notice that the following program arguments are defined for this test case in the Application Arguments field lt jprobe_home gt demos coverage adventure AdvTest1 txt Note These pre defined settings cannot be modified or deleted Also you do not need to integrate your application with JProbe because a startup script is already provided for the Adventure demo Coverage Analysis Demos 61 Adventure Tutorial You are now ready to run a Coverage analysis sess
128. ronimo Console Deploying Game Pack on Geronimo Using the Provided EAR File Use the build properties file and build script provided The following procedure assumes that you have successfully installed and configured the Ant 1 6 3 or later a supported version of Apache Geronimo and JProbe v 8 3 In addition you need to have defined an environment variable called GERONIMO_HOME which points to your Geronimo home directory Also you must have already created a GamepackDB database as specified in section Creating a Database for the Game Pack Demo 98 JProbe Tutorials To deploy the Game Pack demo on Apache Geronimo 1 In the lt JPROBE_HOME gt demos gamepack build directory edit the build properties file a b c Delete the pound sign from the J2EEServer Geronimo statement Add a pound sign in front of the other J2EEServer statements that is J2EEServer JBossWithTomcat and J2EEServer WebLogic10 3 Save the file 2 If it is not already started start the Apache Geronimo application server using the lt GERONIMO_HOME gt bin startup bat file 3 Deploy the Gamepack ear file provided by JProbe in the lt JPROBE_HOME gt demos gamepack support deployment Geronimo directory Use one of the following methods Method 1 Open a command window navigate to the lt JPROBE_HOME gt demos gamepack directory and type the following command ant f build build xml deploy ear Note To undeplo
129. s complete click Next The Run Configuration tab is displayed 15 Select the Close syscon window on exit check box to automatically close the jpsyscon window after the termination of the launched script if the program exits normally 16 To run your application with JProbe using the startup script click Run amp Connect Note To start JBoss using the startup script In Windows C lt jboss_home gt bin run_WithJProbe bat In a UNIX or Linux shell from the directory where you saved the startup script run_WithJProbe sh JProbe Game Pack for JavaEE 113 Advanced Game Pack Evaluation JProbe Execution Console opens and the application server and the Game Pack application start JProbe connects to the Game Pack application and the Runtime Summary view opens in the Console Step 2 Logging in to Game Pack In this step you log in to the Game Pack demo 1 2 Open a Web browser and go to http localhost S8080 gamepack The Game Pack Demo login page appears Enter your User ID and Password then click Login Note The first time you do this you need to create a user name and password for yourself For more information see Creating a User Account for Game Pack on page 134 Alternatively you can use the default user ID password admin admin You are now ready to run a Memory analysis session Step 3 Running the Session In this step you work through a use case by playing three consecutive games It does not ma
130. s faster and easier Visit www quest com for more information Contacting Quest Software Email info quest com Mail Quest Software Inc World Headquarters 5 Polaris Way Aliso Viejo CA 92656 USA Web site www quest com Refer to our web site for regional and international office information Contacting Quest Support Quest Support is available to customers who have a trial version of a Quest product or who have purchased a commercial version and have a valid maintenance contract Quest Support provides around the clock coverage with SupportLink our web self service Visit SupportLink at http support quest com From SupportLink you can do the following e Quickly find thousands of solutions Knowledgebase articles documents e Download patches and upgrades e Seek help from a Support engineer e Log and update your case and check its status View the Global Support Guide for a detailed explanation of support programs online services contact information and policy and procedures The guide is available at http support quest com pdfs Global Support Guide pdf 12 JProbe Tutorials Quest Communities Get the latest product information find helpful resources and join a discussion with the JProbe Quest team and other community members Join the JProbe community at http jprobe inside quest com Memory Analysis Demos This chapter provides a summary of the Memory demo applications that ship with
131. settings cannot be modified or deleted Also you do not need to integrate your application with JProbe because a startup script is already provided for the Diner demo 5 Torun your application startup script and also connect the JProbe Console click Run amp Connect The JProbe Execution Console opens then the Diner program starts displaying a window with icons representing the philosophers The slider controls the number of milliseconds that a Philosopher waits sleeps between chopstick attempts eating You are now ready to connect a JProbe Console and look for a deadlock Start 50 milliseconds Step 2 Running the Diner Session In this step you run the Diner program until a deadlock occurs That said in some cases a deadlock may not occur because the program is sensitive to timing on the computer and in the JVM If the program does not deadlock stop the program adjusting the slider to change the timing then start the program again 44 JProbe Tutorials Note This procedure assumes that the Diner program is already running for instructions on how to execute the startup script see step 5 in section Step 1 Setting Up the Diner Session on page 42 Alternatively you can run the startup script from the command line In a Windows command window Diner bat In a UNIX or Linux shell from the directory where you saved the startup script Diner sh To run the session 1 Inthe Diner program
132. sis tool Chapter 5 JProbe Treasurehunt provides information about the Treasurehunt demo software that ships with JProbe JProbe Documentation Suite The JProbe documentation suite is provided in a combination of online help PDF HTML and TXT Online Help You can open the online help by clicking the Help icon on the JProbe toolbar PDF The complete JProbe documentation set is available in PDF format on SupportLink The PDF documentation can also be found in the Documentation folder on the JProbe DVD The default location of the documentation after an installation is lt jprobe_home gt docs Adobe Reader is required HTML Release Notes are provided in HTML and TXT format The default location of this document after an installation is lt jprobe_home gt docs The Ant Tasks User Manual is also provided in HTML format The default location of this document after an installation is lt jprobe_home gt automation doc To open it navigate to index html Core Documentation Set The core documentation set consists of the following files JProbe Installation Guide PDF JProbe User Guide PDF and online help JProbe Reference Guide PDF JProbe Plugins for Eclipse Guide PDF JProbe Tutorials PDF and online help JProbe Release Notes HTML and TXT Ant Tasks User Manual HTML 10 JProbe Tutorials Feedback on the Documentation We are interested in receiving feedback from you about our documentation For example did you
133. ssful build includes the following types of messages deploy tofolder copy Copying 1 file to lt JBOSS_HOME gt server default deploy echo INFO lt JPROBE_HOME gt demos gamepack dist gamepack ear has been deployed to lt JBOSS_HOME gt server default deploy BUILD SUCCESSFUL Note To compile the Game Pack code use the following command instead ant f build build xml compile 3 Start JBoss using the lt JBOSS_HOME gt bin run bat file 4 To view the Game Pack open a browser and enter http localhost lt port gt gamepack where lt port gt is Tomcat s http port number The default value is 8080 The Game Pack startup welcome page appears You can now exercise the tutorials by clicking the available links For more information see Running Game Pack with the JProbe Application on page 109 Note To rebuild the Game Pack from the source and package and deploy it use ant f build build xml undeploy Deploying the Game Pack on BEA WebLogic Server 10 3 For instructions on how to deploy the Game Pack demo on a BEA WebLogic Server 10 3 application server using the Gamepack ear file for BEA WebLogic Server 10 3 104 JProbe Tutorials provided with Game Pack see section Deploying Game Pack on BEA WebLogic Server 10 3 Using the Provided WebLogic Template JAR File If you want to make any changes in the Game Pack source files then you have to build a new Game Pack EAR file using the updated code and deploy the new
134. t Copy settings for Performance Analysis The settings are copied from the original configuration into Polynomial 1 the new configuration appears in the Configurations Navigator Select Polynomial 1 in the Configurations Navigator The Configuration Details tab is displayed in the View area Click Edit In the Configuration Name text box type PolynomialFixed as the name for the new configuration Click the Java Application tab to change the program argument a Click the browse button beside the Application Arguments field b Inthe upper field of the Application Arguments dialog box delete N and type H c Click Parse Arguments 54 JProbe Tutorials 10 11 The argument appears in the first line of the lower field d Click OK The Application Arguments field displays the program argument Click Save then click Save As to save the configuration file PolynomialFixed_Perf_Settings jpl into your working directory Tip Itis a good practice to save the configuration files into a directory other than the JProbe installation directory for example C JProbeFiles Click Integrate The Integration Wizard appears JProbe validates the configuration file and creates a startup script file for example in Windows PolynomialFixed bat and in UNIX Linux systems PolynomialFixed sh Tip Itis a good practice to save the script files into a directory other than the JProbe installation directory for example C JProbeFiles
135. t Cycling mode demonstrates how over allocating short lived objects can cause the garbage collector to run more frequently than necessary Garbage collection takes time and resources The Normal mode shows that it is often more efficient to reuse strings Before beginning this tutorial you need to deploy the Game Pack to the application server of your choice For more information see Deploying the Game Pack Demo on Your Application Server on page 95 Note The values cited in this tutorial reflect the Game Pack running on the JBoss 5 1 0 application server on Windows XP The following table summarizes the types of information you need to know before starting this tutorial Program Game Pack Demo Match Game Use Case Play three games without quitting Architecture Object Cycling Use string concatenation Normal Append to an existing string buffer object JProbe Game Pack for JavaEE 117 Advanced Game Pack Evaluation Hypothesis The program does not create unnecessary temporary string objects The tutorial walks you through the following steps Step 1 Setting Up the Session and Starting the Game Pack Step 2 Logging in to Game Pack Step 3 Running the Session Step 4 Identifying Object Cycling Step 5 Investigating Object Cycling Step 6 Running the Session with Improved Code Step 1 Setting Up the Session and Starting the Game Pack You use the JProbe configuration tool to create the session settings for this
136. tes clients threads connecting to a server and querying a database Temporary objects are created for the login data and for the connection See the notes in Network java Tutorial Network Tutorial on page 28 Memory Analysis Demos 15 Summary of Demos for Memory Java SE Application Sim class Purpose This example simulates a network model in which a connection is made to verify the identity of the user If the identity of the user is validated the application extracts the desired data from the database and saves it in the result set More Information See the notes in Sim java StalledStack class This example shows how a stalled stack reference can hold objects in memory longer than necessary You could be using the memory consumed by these objects for other tasks Uses heap triggers See the notes in StalledStack java Strings class Compares two algorithms one that creates large allocations of string objects and one that does not See the notes in Strings java JProbe also ships with a Java EE demo application called JProbe Game Pack For more information see JProbe Game Pack for JavaEE on page 67 16 JProbe Tutorials LeakExample Tutorial The LeakExample program illustrates how an obsolete collection reference can anchor entire trees of loitering objects in the Java heap This tutorial demonstrates how to use JProbe to identify loitering objec
137. th JProbe and contains tutorials for some of these applications The source code and compiled classes for the Performance demos are located in the lt jprobe_home gt demos performance directory This chapter contains the following sections Summary of Demos for Performance Piosopher s Diner TOA crc cccies ee teetisecuraested at ennretiv EN 42 Polen ial RGR guea Madsadddansidiansnddadauas 47 40 JProbe Tutorials Summary of Demos for Performance The following table describes the purpose of the example applications Java SE Application Diner class Purpose The application deadlocks This example shows how you can use JProbe to identify the threads involved in a deadlock More Information See the notes in Diner java Tutorial Philosopher s Diner Tutorial on page 42 Files class Compares the performance of two algorithms a buffered Reader Writer versus an unbuffered DataInputStream Data OutputStream See the notes in Files java MethodCalls class This application demonstrates the JProbe s ability to track method calls by allowing the user to control the number of calls to specific methods Each button has a corresponding ActionListener When a button is pressed the actionPerformed method displays a message in the text area The user can see how Performance tracks method calls by comparing Performance s reported number of calls to each method and the data displayed in th
138. the Memory Leak views and discover that the loitering GameHandler objects are being held by an obsolete container reference To look for a solution you open the Source view and review the code for the allocating method To investigate loitering objects 1 Ifthe snapshot is not open right click it in the snapshot navigator and select the Open Instances View The Instances view appears 2 Select Heap Count from the Investigate by list 3 Filter the method list by typing GameHandler in the Filter Classes field and pressing Enter 4 Select the GameHandler class and click Instance Detail 76 JProbe Tutorials The Instance Detail view opens The three loitering GameHandler objects are displayed in the instances list You can see the stack trace of method calls in the Allocated At column Click the Trace tab and scroll down the method list to the methods belonging to the subpackages of the demos gamepack web game package and find a method called EJBControllerimpl startGame The startGame method calls the getGameHandlerRemote method which in turn sets off a series of calls to JBoss methods that eventually causes the bean to be created Therefore the getGameHandlerRemote method is the most likely candidate for investigation because it is the last Game Pack method before the series of application server calls Select the demos gamepack web game EJBControlleriImpl1 getGameHandlerRemo te method right click and se
139. the heap when the game ends The tutorial walks you through the following steps Step 1 Setting Up the Session and Starting the Game Pack Step 2 Logging in to Game Pack Step 3 Running the Session Step 4 Identifying Loitering Objects Step 5 Investigating Loitering Objects Step 6 Running the Session with Improved Code Step 1 Setting Up the Session and Starting the Game Pack You use the JProbe Console to create the session settings for this example In the setup procedure only the settings that you need to change or verify are mentioned If a setting is not mentioned leave it blank or in its default state The following procedure assumes that you are running JProbe locally on your computer To set up the session and start Game Pack 1 On the JProbe Console click Configurations gt New Configuration The New Configuration Wizard dialog box appears Click JBoss gt JBoss v5 x Provide a name for this configuration in the Configuration Name text box for example LoiteringObjects then click Next Type the path to your server startup script in the text field or click the browse button J and navigate to it then click Next In the My Code tab in the Elements area type the path to the deployed gamepack ear file for example lt jprobe_home gt demos gamepack support deployment JBoss WithTomcat gamepack ear or click the browse button J and navigate to it Click Create Filters The table is populated with the
140. the source of most of the String and StringBuffer instances that we saw in the Instances view You can now proceed with fixing the code Step 5 Running the Network Session with Improved Code Two key problems were discovered in the code temporary connection objects are created for each connection to the database and temporary strings are created to pass login password and query information The program contains fixes to reduce the number of temporary objects You need to add program arguments to use the fixed code You can run the code with one or both of the fixes For the connection issue use the fc application argument This problem is solved by implementing a cache If you review the cache fix in Sim java you will notice that there are actually three caching options documented SimpleCache PoolCache and LocalCache By default the LocalCache fix is used If you change the cache you need to recompile the program For the login issue use the 1 application argument The problem is solved by introducing static String and StringBuffer classes that can be reused To verify that the fixed code improves memory use 1 Inthe Configurations Navigator right click Demo Network Memory Analysis and select Copy settings for Memory Analysis The settings are copied from the original configuration into Demo Network Memory Analysis 1 the new configuration appears in the Configurations Navigator 2 Select Demo Network Memory Analysis
141. third party methods that are called by one of the Game Pack methods To identify the performance bottleneck 1 In the Summary view select one of the top methods suggested for investigation java awt MediaTracker waitForID int in the Performance Hotspot section right click and select Investigate The Methods view appears 2 Select Hot Methods Elapsed Time from the Color to Show list Tip You can change the default Red Gray color scheme Right click the color scale located between the graph and the list and select a different color scheme 3 In the Call Graph identify the critical node In this example it is the last node on the right side MediaTracker waitForID 4 Hover over the MediaTracker waitForID node to display its tooltip You can see that the Elapsed Method Time is 495 ms and it is called 600 times Note The actual number for time and calls for the function wait ForID can vary depending upon how many times the minesweeper image is being displayed Conclusion The performance bottleneck is caused by the Game Pack method renderMineMapImage_MethodTime calling these expensive third party methods for every tile in the game board Step 6 Running the Session with Improved Code After you discover the performance bottleneck you can review the source code and choose the best way to fix your code You could attempt to call a less expensive method or you might choose an entirely new algorithm to do the same task
142. tion Step 4 Merging the Test Results In this step you merge the snapshots taken during Step 3 Running the Session to get a complete picture of the coverage provided by these two test cases You merge the snapshots using the jpcovmerge command line tool To merge the snapshots 1 Click Start gt Run and type the following then click OK e Ina Windows command window lt JPROBE_HOME gt bin jpcovmerge lt working_directory gt coverage_normal jpc lt working_directory gt coverage_loitering jpc lt working_directory gt coverage_merged jpc e Ina UNIX or Linux shell lt JPROBE_HOME gt bin jpcovmerge lt working_directory gt coverage_normal jpc lt working_directory gt coverage_loitering jpc lt working_directory gt coverage_merged jpc Important This command fails if lt jprobe_home gt or lt working_directory gt has spaces in it You must quote the application arguments in this case 2 On the JProbe Console click File gt Open Snapshot 3 In the Open dialog box select lt working_directory gt coverage_merged jpc and click Open The merged snapshot is selected and its content is displayed in the Snapshot Browser view Step 5 Assessing Your Test Coverage After merging your test cases you are now ready to investigate your results By default JProbe displays results in terms of misses A miss means that the code was not called during your test cases To investigate your results 1 In the Snapshot Browser
143. tion The Game Pack startup welcome page appears You can now exercise the tutorials by clicking the available links For more information see Running Game Pack with the JProbe Application on page 109 Deploying the Game Pack Demo on JBoss For instructions on how to deploy the Game Pack demo on a JBoss application server using the Gamepack ear file for JBoss provided with Game Pack see section Deploying Game Pack on JBoss Using the Provided EAR File If you want to make any changes in the Game Pack source files then you have to build a new Game Pack EAR file using the updated code and deploy the new EAR file instead For instructions on how to deploy the Game Pack demo on a JBoss application server using a customized EAR file see section Building and Deploying Game Pack on JBoss Deploying Game Pack on JBoss Using the Provided EAR File Use the build properties file and build script provided The following procedure assumes that you have successfully installed and configured the Ant 1 6 3 or later a supported version of JBoss and JProbe v 8 3 In addition you need to have defined an environment variable called JBOSS_HOME which points to your JBoss home directory To deploy the Game Pack demo on JBoss default server 1 In the lt JPROBE_HOME gt demos gamepack build directory edit the build properties file a Delete the pound sign from the J2EEServer JBossWithTomcat statement b Add a pound sign
144. to run with the tutorial The java executable is lt jprobe_home gt bin jre bin java exe Click Next 18 JProbe Tutorials The My Code tab is displayed 12 In the Category Program Name text box type LeakExampleDemo which specifies the name of the category in which you want to include your code then click Next The Analysis Type tab is displayed 13 Select the Memory Analysis option 14 To disable the data recording at initial JVM start select Data Recording Off on the Initial Recording tab 15 Click Next The Advanced JProbe Options tab is displayed 16 In the Snapshot Basename text box type memoryleak_ and then click Next The Summary tab is displayed It presents a summary of the settings defined for your configuration Configuration Name LeakExample Edit Configuration Type Java Application Edit Main Class demos memory leakexample LeakExample Edit Application Arguments Edit Working Directory C Quest_Software JProbe_8 3 Edit Classpath C Quest_Software JProbe_8 3 Edit Java Executable C Quest_Software JProbe_8 3 bin jre bin java exe Edit Java Options Edit Category Program Name LeakExampleDemo Edit Analysis Type memory Edit Advanced JProbe Options Edit JProbe Port 52991 Edit Snapshot Basename memoryleak_ Edit JProbe Settings File 17 To create a JPL file and a startup script click Save amp Integrate 18 Click Save to save the configuration file LeakExample_Mem_Settings jpl into your working dir
145. ts in your code and how to reclaim memory by removing loitering JButton objects The improved code shows a 89 15 improvement in how much memory is used by the instances allocated by LeakExample methods and a 37 73 improvement in the overall memory used for the entire program Note The values cited in this tutorial reflect the LeakExample running on Windows XP with Sun JDK delivered with JProbe You may see different values on your system but the improvement in memory use should still be evident The following table summarizes the types of information you need to know before starting this tutorial Program LeakExample class Use Case Add buttons to a panel Remove buttons from a panel Architecture Uses the class JButton to create buttons Hypothesis JButton objects are removed from the heap when the buttons are removed from the panel This tutorial assumes that you are running JProbe on your local machine You can find more information about loitering objects in the JProbe User Guide This tutorial walks you through the following steps e Step 1 Setting Up the Memory Leak Session e Step 2 Running the Memory Leak Session e Step 3 Identifying Loitering Objects e Step 4 Investigating Loitering Objects e Step 5 Running the Memory Leak Session with Improved Code Memory Analysis Demos 17 LeakExample Tutorial Step 1 Setting Up the Memory Leak Session In this step you use the JProbe Console to create the session s
146. tter for the analysis whether you win or lose the games However it is important that you start a session before you begin to play or JProbe will not perform a garbage collection After you have played three games you end the session and JProbe takes a snapshot To run a game with the Loitering Objects fault 1 In the Game Pack demo click Play beside either Minesweeper or Match Game Note Both games have the same loitering object problem Select the Loitering Objects option Note Clicking the link displays the option s definition j In the JProbe Runtime Summary view click Set Recording Level on the toolbar In the Set Recording Level dialog box select Record Allocations and Stack Traces For All Instances then click OK In the Game Pack demo click Start and play the game When the game ends play the game twice more without quitting for a total of three complete games Click Quit 114 JProbe Tutorials 8 Inthe Runtime Summary view click Set Recording Level on the toolbar 9 In the Set Recording Level dialog box select Data Recording Off then click OK JProbe takes a snapshot and displays it in the Snapshots Navigator 10 In the Snapshots Navigator right click the snapshot select Save Snapshot As and navigate to where you want to save the snapshot 11 Name the snapshot loitering_objects and click Save The snapshot name is displayed in the Snapshots Navigator 12 Click Detac
147. ttings jpl into your working directory Tip Itis a good practice to save the configuration files into a directory other than the JProbe installation directory for example C JProbeFiles Click Integrate 11 Coverage Analysis Demos 63 Adventure Tutorial The Integration Wizard appears JProbe validates the configuration file and creates a startup script file for example in Windows Adventure_TestCase2 bat and in UNIX Linux systems Adventure_TestCase2 sh Tip Itis a good practice to save the configuration files into a directory other than the JProbe installation directory for example C JProbeFiles In the Integrate tab use the browse button to navigate to your working directory and click Save to save the startup file Click Next The Run Configuration tab is displayed Select the Close syscon window on exit check box and click Run amp Connect The JProbe Execution Console opens and the program runs using the text file as test case input for choices When the program is finished the command window closes JProbe takes a coverage snapshot and displays it in the Snapshots Navigator and in the Snapshot Browser view Close the Snapshot Browser view Step 5 Merging the Test Case Results In this step you merge the snapshots taken during Step 3 Running the First Test Case and Step 4 Setting Up and Running the Second Test Case to get a complete picture of the coverage provided by these two test cases You mer
148. ttleneck Java EE 83 122 deadlock Java SE 42 inefficient algorithm Java SE 47 Performance Bottleneck tutorial 83 122 Polynomial tutorial 47 R running Game Pack with JProbe 109 S support 11 T technical support 11 text conventions 10 Treasurehunt 137 tutorials coverage case effectiveness Java SE 59 Java EE 89 129 memory leak example Java SE 16 loitering objects Java EE 71 110 object cycling Java EE 77 116 object over allocation Java SE 28 performance bottleneck Java EE 83 122 Index 141 deadlock Java SE 42 inefficient algorithm Java SE 47 U using Treasurehunt 138 142 JProbe Tutorials
149. utorials 5 6 10 11 12 Step 4 In the Game Pack click Start and click on several tiles until you are blocked Click Quit In the Runtime Summary view click Set Recording Level on the toolbar In the Set Recording Level dialog box set the slider to select Data Recording Off then click OK JProbe takes a snapshot and displays it in the Snapshots Navigator In the Snapshots Navigator right click this snapshot select Save Snapshot As and navigate to where you want to save the snapshot Name the snapshot minesweeper_methodtime and click Save The new name is displayed in the Snapshots Navigator Click Detach From Session F The Summary view appears after a few seconds Note If a different snapshot is already opened in the JProbe Console the new snapshot taken does not open automatically To open it right click the snapshot name in the Snapshot navigator and select Open Snapshot On the Game Pack demo page click Logout then close the browser Identifying the Performance Bottleneck In this tutorial you use the Performance views to identify a hotspot A hotspot is an expensive method one that takes more time than necessary to run The hotspot method may b e the performance bottleneck or the method may call another method that causes the slowdown In this example you find two expensive third party methods that are called by one of the Game Pack methods To identify the performance bottlenec
150. view expand the class tree in the upper pane to show all of the classes in demos gamepack minesweeper as this is the game that was exercised 2 Click the Missed Methods column heading in the upper pane to sort the table from highest to lowest percentage of missed methods 134 JProbe Tutorials Methods are missed in several classes MineSweeperException MineSweeperModel MineSweeperScore MineSweeperSnapshot MineSweeperMove and MineSweeperRenderer We will investigate the first two classes In the upper pane select the MineSweeperModel class The methods for this class are displayed in the lower pane Select the play method right click and select Show Source to open the lt JPROBE_HOME gt demos gamepack src demos gamepack ninesweeper MineS weeperModel java source code The source code opens at a block of missed lines that are in an if statement so you know that the test case missed a condition Click the Down 7 button at the top of the coverage bar to the right of the scroll bar to move to the next set of missed lines Continue in this way until you have examined all the missed blocks of code then move on to the next missed class Tip Once you identify an area for improvement you can modify the test suite and redo the tutorial to see the improvement in overall coverage Creating a User Account for Game Pack The first time that you start the Game Pack you need to create a user account for yourself To cr
151. y Game Pack in a command window navigate to lt JPROBE_HOME gt demos gamepack and type the following command ant f build build xml undeploy Method 2 Open a command window navigate to the lt GERONIMO_HOME gt bin directory and type the following command deploy bat user system password manager deploy lt JPROBE_HOME gt demos gamepack support deployment Geronimo Gamepack ear Note To undeploy Game Pack in a command window navigate to lt GERONIMO_HOME s bin and type the following command deploy bat user system password manager undeploy gamepackear gamepack ear 1 0 ear A successful build includes the following types of messages Buildfile build build xml deploy ear deploy ear deploy Geronimo error deploy Geronimo deploy toScript error JProbe Game Pack for JavaEE 99 Advanced Game Pack Evaluation deploy toScript exec Using GERONIMO_HOME lt GERONIMO_HOME gt exec Using GERONIMO_TMPDIR var temp exec Using JRE_HOME C Program Files Java jdk1 6 0_10 jre exec Deployed gamepackear gamepack ear 1 0 ear exec gt GamepackWeb war gamepack exec gt GamepackEJB jar exec gt GamepackDataSource echo INFO lt JPROBE_HOME gt demos gamepack dist gamepack ear has been deployed to lt GERONIMO_HOME gt Geronimo Server BUILD SUCCESSFUL To view the Game Pack open a browser and type http localhost lt port gt gamepack where lt port
152. you have examined all the missed blocks of code then move on to the next missed class You have identified an area for improvement If you like you can modify the test suite and redo the tutorial to see the improvement in overall coverage 66 JProbe Tutorials 4 JProbe Game Pack for JavaEE This section describes how to deploy the JProbe Game Pack demo software and presents how to use JProbe with JavaEE applications that require a third party application server The Game Pack tutorials describe how to find two different kinds of memory leaks with the Memory analysis tool how to investigate a performance bottleneck with the Performance analysis tool and how to assess code coverage with the Coverage analysis tool Note Results obtained while running the Game Pack tutorials vary depending on the application server you are using This chapter contains the following sections Getting Started with the Game Pack D MO0 cccsesctessesessesesestesneeeeseeseesteatestesteetesneetesneeteaneess 68 Quick Game Pack EYAYE iid acara ici iiteeniasnws ada a Ei 70 Advanced Game Pack Evitado onnaa aaa e 95 Creating a User Account for Game Pack ssss sssesssssrrssensssnrreeensssnrintennsnritrtennsnnrinrennnnrrnrennnnna 134 Game Pack KNOWN ISS inni ararat aaveivadeui ein Gaerene 135 68 JProbe Tutorials Getting Started with the Game Pack Demo Refer to these sections for information about the following topics e Installing the Game
153. ysis Tutorial cescesecseseseessesssseesesneesnseseensesneenieeneeaeeseesneesneenneeteeneesseenesees 83 Game Pack Coverage Analysis Tutorial c scssesesessesseeseessesseessesessneesnssnsesnsesteenseeneeneesiesneeseeieeeteeneeseennesees 89 Advanced Game Pack Evaluations iassa iieii E EEA N adnan 95 Deploying the Game Pack Demo on Your Application S rver cesessesesecseseeseeseesseseensesneenesntesteeseeeenesees 95 Running Game Pack with the JProbe Application ceseesseeseseeseseseeeseesseestesseeseesssneeseeneeenseaneenteneenteanee 109 Table of Contents 5 Game Pack Memory Analysis Tutorials s sssessessscsessessessessessesssssnsenssessuseusssseuseassasesesansensansensensetsateaneaneateanes 110 Game Pack Performance Analysis Tutorial ccsesssessessesseseesesssesseesesseesneeseeseesnsessensesnseateesteeteensenneeneennees 122 Game Pack Coverage Analysis Tutorial Creating a User Account for Game Pack Game Pack Known Issues JProbe TreaSurehunt sccssccescasssecsscsseceatosseecascstesrateateecascstescarsatuecuscseeseatedtuecatestescutustuecutsstnceatestencuesabeteatateecutsates 137 Installing the Treasurehtint DeM0 wessseecvenar 2 atewaveracnnwannanetdnnauraninaaneniann E a 138 Using the Treasurehunt Demo ssccsessessessessssesseesessesetesesesessessecsecsessssessasenessseseenseseesteneesteaseneeseenteateneeaesaeeseeeneess 138 6 JProbe Tutorials Introduction to This Guide This chapter

Download Pdf Manuals

image

Related Search

Related Contents

Hanson QUATTRO MANUAL V1 0  9CL-1100622  BA PSENsgate2 - Electrocomponents  Canon EOS 500DB  Panas。nー。 LEDスボツ トライ ト (屋外用) 取扱説明書  

Copyright © All rights reserved.
Failed to retrieve file