slide1
Download
Skip this Video
Download Presentation
Diagnosing Your Application on the JVM

Loading in 2 Seconds...

play fullscreen
1 / 28

Diagnosing Your Application on the JVM - PowerPoint PPT Presentation


  • 127 Views
  • Uploaded on

Diagnosing Your Application on the JVM. Staffan Larsen Java SE Serviceability Architect [email protected] @stalar. Notice.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Diagnosing Your Application on the JVM' - river


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
diagnosing your application on the jvm
Diagnosing Your Application on the JVM

Staffan LarsenJava SE Serviceability Architect

[email protected]

@stalar

notice
Notice

THE FOLLOWING IS INTENDED TO OUTLINE OUR GENERAL PRODUCT DIRECTION. IT IS INTENDED FOR INFORMATION PURPOSES ONLY, AND MAY NOT BE INCORPORATED INTO ANY CONTRACT. IT IS NOT A COMMITMENT TO DELIVER ANY MATERIAL, CODE, OR FUNCTIONALITY, AND SHOULD NOT BE RELIED UPON IN MAKING PURCHASING DECISION. THE DEVELOPMENT, RELEASE, AND TIMING OF ANY FEATURES OR FUNCTIONALITY DESCRIBED FOR ORACLE\'S PRODUCTS REMAINS AT THE SOLE DISCRETION OF ORACLE.

slide4

404 – Not Found

java.security.AccessControlException: access denied ("java.lang.management.ManagementPermission" "control")

at java.security.AccessControlContext.checkPermission(AccessControlContext.java:364)

at java.security.AccessController.checkPermission(AccessController.java:555)

at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)

at oracle.jrockit.jfr.JFR.checkControl(JFR.java:43)

at oracle.jrockit.jfr.RepositoryChunk.<init>(RepositoryChunk.java:68)

at Demo$1.<init>(Demo.java:14)

at Demo.start(Demo.java:14)

at sun.applet.AppletPanel.run(AppletPanel.java:474)

at java.lang.Thread.run(Thread.java:722)

slide5

jstack

attach

JMX

jinfo

jstatd

jps

jvisualvm

jstat

jcmd

perf counters

jmap

serviceability agent

remote access
Remote access
  • JMX
    • jvisualvm, jconsole
    • Access information from java.lang.managementMBeans
    • SSL and authentication
    • Enable startup: -Dcom.sun.management.jmxremote
    • Enable runtime: jcmdManagementServer.start
  • jstatd
    • Daemon that runs on remote machine
    • jstat can connect to daemon

New!

discovery
Discovery

What is running on my system?

  • Well-known file for each JVM
    • <temp>/hsperfdata_<user>/<pid>
    • /tmp/hsperfdata_staffan/3636
  • Created on JVM startup
  • Deleted on JVM shutdown
  • Unused files deleted on startup
java discovery protocol
Java Discovery Protocol

JDP

From freedigitalphotos.net/by digitalart

attach
Attach

Talking to the JVM

  • Allows sending "commands" for execution in the JVM
  • Receive text output
  • Local access by same user only
  • Used by jcmd, jstack, jmap
  • Mechanics differ on platforms
attach linux bsd solaris
Attach: Linux / BSD / Solaris
  • Create file /tmp/.attach_pid<pid>
  • Send SIGQUIT to JVM
  • JVM looks for /tmp/.attach_pid<pid>
    • If not found a normal thread dump is done
  • JVM will create /tmp/.java_pid<pid> socket
  • Use socket for communication
  • Solaris uses door API instead of socket
attach windows
Attach: Windows
  • Remote process injects code (!) into the JVM
    • VirtualAllocEx / WriteProcessMemory
  • Remote process creates a thread in the JVM to call the code
    • CreateRemoteThread
  • The code dynamically looks up JVM_EnqueueOperation() and calls it
  • Reads result from a pipe
diagnostic commands
Diagnostic Commands
  • Helper routines inside the JVM
  • Text output
  • Executed via the jcmd utility (soon JMX)
  • Self-describing help facility
  • Different set of commands for different JVM versions

Coming Soon!

j vmstat perfcounter
jvmstat / PerfCounter
  • /tmp/hsperfdata_staffan/3636
    • Contains a lot of run-time information about the JVM
  • Memory mapped file
  • Updated continuously by JVM
  • Use jstat to show information in readable form
  • Use "jcmd PerfCounter.print" to see raw contents
accessing the jvm
Accessing the JVM

jcmd

jstack

jmap

jinfo

Monitored JVM

JMX

JMX

RMI

j*

jstat(d)

jstat

JMX client

dcmd

JVM

attach

jvmstat

attach

Mission Control

VisualVM

JConsole

serviceability agent
Serviceability Agent
  • For core-files or non-responsive JVMs
  • Uses debugger to read information
  • Last resort - suspends process in unknown state

jstack <executable> <core>

jstack –F <pid>

accessing the jvm1
Accessing the JVM

jstack

jmap

jinfo

Monitored JVM

j*

JVM

vmSymbols

SA

debugger

java mission control
Java Mission Control
  • Java Mission Control
java flight recorder
Java Flight Recorder
  • JVM-built-in profiler and tracer
  • Non-intrusive
  • Always-on
  • Circular buffers
  • Captures both JVM and application data
    • GC, Locks, Compiler, Exceptions, CPU Usage, I/O, … …
  • After-the-fact analysis

New!

Photograph by Jeffrey Milstein

http://butdoesitfloat.com/In-the-presence-of-massive-gravitational-fields-this-perfect

future
Future

It’s soon here!

  • More Diagnostic Commands (jcmd)
    • Eventually replacing jstack, jmap, jinfo
  • JMX 2.0
  • Improved Logging for the JVM
    • JEP 158
  • Deprecate JConsole, hprof agent (?)
take away
Take-away
  • Know which tools exists
  • Seen the tools in use
  • Something new and something useful
  • Go and experiment with the tools!

@stalar

[email protected]

[email protected]

ad