29
Take advantage of Memory Analyzer Tool inside your Continuous Integration Aurélien Pupier R&D Engineer, Studio Development Leader @apupier ©2014 Bonitasoft

Take advantage of memory analyzer tool inside your continuous integration

Embed Size (px)

DESCRIPTION

During this presentation, I will demonstrate how to generate an automatic custom memory report integrated in a Continuous Integration. It detects memory leaks very early in development process and provides a preliminary report. The Bonitasoft team implemented such a solution with the Hudson continuous integration server and the Memory Analyzer Tool (MAT) on our Eclipse RCP application. This talk will be an opportunity to share our experience and present the steps to achieved the goal: Take a Heap Dump programmatically at the end of Test execution Create a custom MAT report or use the ones provided Launch MAT reports analysis on the Heap Dump Integrate reports analysis in the Hudson/Jenkins job

Citation preview

Page 1: Take advantage of memory analyzer tool inside your continuous integration

Take advantage of Memory

Analyzer Tool inside your

Continuous Integration

Aurélien Pupier R&D Engineer, Studio Development Leader

@apupier

©2014 Bonitasoft

Page 2: Take advantage of memory analyzer tool inside your continuous integration

Agenda

• Why using MAT?

• How to

– Programmatic Heap Dump

– Choose your report

– Headless report generation

– CI integration

• Going further

©2013 Bonitasoft 2

Page 3: Take advantage of memory analyzer tool inside your continuous integration

Why using MAT?

©2013 Bonitasoft 3

Page 4: Take advantage of memory analyzer tool inside your continuous integration

Before – how we detect Memory Leak? (1/3)

• Manual QA tests

©2013 Bonitasoft 4

Page 5: Take advantage of memory analyzer tool inside your continuous integration

Before – how we detect Memory Leak? (2/3)

• Client

©2013 Bonitasoft 5

Page 6: Take advantage of memory analyzer tool inside your continuous integration

Before – how we detect Memory Leak? (3/3)

• Dumb performance tests

– Dedicated test suite

– Open 100 diagrams

– Only very big OOM

– Check no crash

©2013 Bonitasoft 6

Page 7: Take advantage of memory analyzer tool inside your continuous integration

Unit Test Integration

Test Performance

Test Manual QA

Test Client

Detect early

©2013 Bonitasoft 7

It’s

complicated It’s

com

plic

ate

d

Page 8: Take advantage of memory analyzer tool inside your continuous integration

How to

©2013 Bonitasoft 8

Page 9: Take advantage of memory analyzer tool inside your continuous integration

Required materials

©2013 Bonitasoft 9

Page 10: Take advantage of memory analyzer tool inside your continuous integration

Programmatic Heap Dump

©2013 Bonitasoft 10

Page 11: Take advantage of memory analyzer tool inside your continuous integration

Heap Dumper Java code

• Mbean

– com.sun.management:type=HotSpotDiagnostic

• JVM-specific

©2013 Bonitasoft 11

Page 12: Take advantage of memory analyzer tool inside your continuous integration

When?

• All tests played and finished

– Memory should be clean

– Take care to close everything

• End of Test Suite

©2013 Bonitasoft 12

Page 13: Take advantage of memory analyzer tool inside your continuous integration

When? Afterclass

©2013 Bonitasoft 13

Page 14: Take advantage of memory analyzer tool inside your continuous integration

Plug-in specificity

• Extension point used

– Avoid JVM dependency

• Extract interface for HeapDumper

• Close project Eclipse compiler mic-mac

©2013 Bonitasoft 14

Page 15: Take advantage of memory analyzer tool inside your continuous integration

Global picture

©2013 Bonitasoft 15

MBean provider

Heap Dumper Extension point

Test suite executor

Heap Dumper Provider

Page 16: Take advantage of memory analyzer tool inside your continuous integration

Choose your report

Find your happiness… or create it

©2013 Bonitasoft 16

Page 17: Take advantage of memory analyzer tool inside your continuous integration

Provided

©2013 Bonitasoft 17

Page 18: Take advantage of memory analyzer tool inside your continuous integration

Custom report

• AllTests_custom_html\index.html

©2013 Bonitasoft 18

Page 19: Take advantage of memory analyzer tool inside your continuous integration

Headless report generation

MAT – “There’s an app for that”

©2013 Bonitasoft 19

Page 20: Take advantage of memory analyzer tool inside your continuous integration

Headless report generation

• Generate report

– org.eclipse.mat.api.parse <dumpFile> <reportId>

– Leak suspects id: org.eclipse.mat.api:suspects

• Unzip reports

– Keep <report-name>_html

– Clean folder

• *.zip

• *.index

• *.threads

©2013 Bonitasoft 20

Page 21: Take advantage of memory analyzer tool inside your continuous integration

CI Integration

©2013 Bonitasoft 21

Page 22: Take advantage of memory analyzer tool inside your continuous integration

Build steps – Generate report

©2013 Bonitasoft 22

Page 23: Take advantage of memory analyzer tool inside your continuous integration

Build steps – Use reports

©2013 Bonitasoft 23

Page 24: Take advantage of memory analyzer tool inside your continuous integration

Reports availability

©2013 Bonitasoft 24

Page 25: Take advantage of memory analyzer tool inside your continuous integration

Fail the build

• Custom script parsing report

– Custom for each report

– Define your own thresholds

• Last build step

• Return value != 0

©2013 Bonitasoft 25

Page 26: Take advantage of memory analyzer tool inside your continuous integration

Going further

©2013 Bonitasoft 26

Page 27: Take advantage of memory analyzer tool inside your continuous integration

Possible improvements

• Provide an Hudson/Jenkins plugin for MAT

– Download

– Pre-defined list of available reports

– Pre-defined thresholds to fail the build

– Conditional Launch (only for Nightly?)

– Group reports

• MAT

– Allow to return a status code when generating report

– Handle thresholds

– Use compare feature

©2013 Bonitasoft 27

Page 28: Take advantage of memory analyzer tool inside your continuous integration

©2013 Bonitasoft 28

Page 29: Take advantage of memory analyzer tool inside your continuous integration

Evaluate This Session

Sign-in: www.eclipsecon.org

Select session from schedule

Evaluate:

1

2

3