用法
- 創建一個名爲ctrlhandler.act的文件。
- 向ctrlhandler.act文件添加命令(參見下文命令列表)。
- 以“stop”結束文件,這是結束文件分析的保留命令。
- 按下ctrl-break,每一個命令都將以出現的順序執行。
JRockit首先會在當前工作目錄查找該文件。如果未找到,JRockit將在JVM目錄中查找。如果仍然沒有的話,JRockit將回退以生成一個常規的線程堆棧轉儲。JRockit將在每次按下ctrl-break時讀取act文件,因此用戶可以在方便時重新配置該文件,而同時JRockit仍在運行。
這裏給出一個示例act文件,它首先打印時間戳,然後是用於啓動JRockit的命令行,最後是一個線程堆棧轉儲。它還包括可以用於act文件的有用命令的列表:
# Example ctrlhandler.act file timestamp command_line print_threads stop # set_filename filename=<file> [append=true] # Sets the file that all handlers following this command will # use for printing. You can have several set_filename commands # in a file. It takes two arguments: filename and an optional # append to specify if you want to append to the file # or overwrite it. Default is to overwrite the file. # timestamp # Prints a timestamp. # print_threads # The normal thread dump. # verbosity [args=<components>] [filename=<file>] # Changes the verbosity level normally specified with -Xverbose. # version # Prints JRockit version information. # command_line # Prints the command line used to start JRockit. # print_object_summary # Prints heap usage statistics (how much heap is used per class), # together with a delta on how much this has changed since # the last invocation of this ctrl-break handler. # print_memusage # Prints a memory usage report of how JRockit is using # the memory. # heap_diagnostics # Prints a detailed report of the heap, including ascii graphics # over the heap layout. # print_class_summary # Prints all loaded classes. # print_utf8pool # Print all UTF8 strings. # jrarecording [filename=<file>] [time=<time>] [nativesamples=true] # Starts a JRA recording. # run_optfile [filename=<file>] # See OptFile. # start_management_server # Starts the new JMX-based management agent. # kill_management_server # Stops the management agent. # start_rmp_server # Starts the old management server (actually the listening # socket that in turn starts servers whenever a connection # is established). # kill_rmp_server # Stops the old management server (actually shuts down the # listening socket). The only reason it isn't named # kill_rmp_server is that stop is a reserved keyword # that stops the parsing of the act file. ;) # help [ctrl-break handler] # Prints all available ctrl-break handlers if no argument # is specified, or help for the specified ctrl-break handler. # memleakserver [port=<port>] # Toggles the memleakserver. If it hasn't been started # it will be started. If it has already started, it will be # shut down. The default port is 7095. # verbose_referents action=[heap|full|nursery|start|stop] # Print verbose reference information. # Parameters: # action=[heap|full|nursery|start|stop] # heap - trigger a heap collection and output reference # information # full - trigger a full heap collection (clears softly # reached soft referents) # nursery - trigger a nursery collection (heap collection # if running without nursery) # start - start writing reference information to default # verbose stream # stop - stop writing reference information # print_exceptions # exceptions=[true|all|false] stacktraces=[true|all|false] # Enable printing of Java exceptions thrown in the VM. # Parameters: # exceptions - print exceptions # stacktraces - print exceptions with stacktraces # At least one of the parameters is required. # Values for the parameters can be "true|all|false" # true - print all exceptions # except java/util/EmptyStackException, # java/lang/ClassNotFoundException and # java/security/PrivilegedActionException # all - print all exceptions # false - don't print exceptions # To turn exception printing off completely you need to set # exceptions = false even if it was turned # on by stacktraces = true.
JRCMD 使用JRCMD實用工具是一種新的調用Ctrl-Break Handler的便捷方式,可在JRockit發行版的bin目錄中找到它。 用法 jrcmd <PID> <command> <parameters>
JRCMD
使用JRCMD實用工具是一種新的調用Ctrl-Break Handler的便捷方式,可在JRockit發行版的bin目錄中找到它。
用法 jrcmd <PID> <command> <parameters>
- PID = 要在其中執行Ctrl-Break Handler的JRockit進程的進程ID。
- command = 要執行的Ctrl-Break Handler命令。
- parameters = Ctrl-Break Handler的參數。
如果不指定選項(或者只指定-P),那麼將顯示運行在本地機器上的所有JRockit的進程ID。如果PID設爲0,那麼命令將發送給在本地機器上運行的所有JRockit JVM。
要列出特定的JRockit中有哪些Ctrl-Break Handler可用,可以使用help命令:
jrcmd <PID> help
要想獲得某個具體的Ctrl-Break Handler的幫助信息,需要在help後添加Ctrl-Break Handler的名稱,比如:
jrcmd 0 help kill_management_server
也可以使用JRCMD列出指定進程的性能計數:
jrcmd <PID> -l