DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Coding
  3. Languages
  4. Pitfalls Experienced When Profiling Tomcat Webapps with VisualVM and NetBeans

Pitfalls Experienced When Profiling Tomcat Webapps with VisualVM and NetBeans

Jakub Holý user avatar by
Jakub Holý
·
Mar. 01, 12 · Interview
Like (0)
Save
Tweet
Share
17.02K Views

Join the DZone community and get the full member experience.

Join For Free

profiling a webapp running on tomcat with visualvm or netbeans wasn’t as easy as expected, so this is a brief record of what to avoid to succeed.

environment: mac os x, java jdk 1.6.0_29, netbeans 7.1, visualvm 1.3.3 (installed separately), tomcat 6.

the pitfalls:

visualvm

  • visualvm sampler and profiler: to be able to drill down to the slow methods you need to take a snapshot before you stop the sampling/profiling (there is a [snapshot] button above the hot spots list). this is not very intuitive and the interface doesn’t communicate it.
  • visualvm profiler: excludes thread.sleep() & object.wait() time (as opposed to the netbeans profiler where you can choose to include/exclude them) => if you method is spending lot of time waiting for a lock, you won’t discover it
  • you might need to allow unsafe, passwordless jmx connections in your tomcat config, see resources

netbeans profiler

  • while visualvm was able to dynamically connect to my tomcat, netbeans wasn’t able to do it and hasn’t provided any notification about the failure. the only visible manifestation was that it wasn’t showing and collecting any data. solution: use the “direct” attach invocation, i.e. starting the target java application with the netbeans profiling agentlib.

tools overview

visualvm

extremely useful tool, included in jdk since 6.0 (command line: jvisualvm) or on the visualvm page .

  • automatically discovers local java processes and can connect to them (if they run java 6+)
  • monitoring – threads, heap, permgen, cpu, classes
  • sampler – low-overhead profiling tool (takes thread snapshot at regular intervals and compares their stack traces to find out where most time is spent)
  • plugins, such as mbeans, tracers
  • profiler – a simpler version of netbeans profiler ( comparison here ); it can dynamically attach to running (java 6+) processes and instrument classes on-the-fly. the not very visible checkbox settings in the right-top corner can be used to set the classes to start profiling from (syntax: my.package.** to include subpackages or my.package.* or my.pkg.myclass) and the packages not to / only to profile (syntax differs here: my.package.* to include subpackages or my.package. or my.pkg.).

resources

  • experience :-)
  • profiling with visualvm, part 1 (6/2008) and part 2 , including comparison with the full nb profiler
  • profiling tomcat with visualvm on mac os x – including jmx setup in tomcat

from http://theholyjava.wordpress.com/2012/02/25/profiling-tomcat-webapp-with-visualvm-and-netbeans-pitfalls/

NetBeans Apache Tomcat

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Specification by Example Is Not a Test Framework
  • Spring Cloud
  • GitLab vs Jenkins: Which Is the Best CI/CD Tool?
  • Master Spring Boot 3 With GraalVM Native Image

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: