When you open a Support ticket for Wowza Streaming Engine™ media server software, the Support engineers at Wowza Media Systems™ may ask you to provide a Java heap dump file. This article describes how to get a dump of the Java heap on Wowza Streaming Engine.
Before you start
Before you go through the steps in this article to create the Java heap dump file, ensure you've consistently replicated the issue. You should also capture the heap dump information before restarting Wowza Streaming Engine. This helps to create a snapshot of the application's memory and the Java process at the particular point in time when the issue occurred.
Install Java JRE or JDK
To use this method, Wowza Streaming Engine must be running the full Java JRE or JDK, which includes the jcmd tool. By default, Wowza Streaming Engine installs with a custom version of the Java JRE. In order to run the jcmd command, you must first complete these steps.
Notes: Starting with Wowza Streaming Engine 4.8.28, we're including the jdk.jcmd Java module with the JRE that ships with the installer. This eliminates the need to complete the steps in this section. For more, see Wowza Streaming Engine support for Java.
- Download and install the full version of the Java JRE or JDK.
- Set your installation of Wowza Streaming Engine to point to the full Java JRE or JDK you just installed. See Manually install and troubleshoot Java on Wowza Streaming Engine.
Create a Java heap dump using jcmd
This section describes creating a Java heap dump using jcmd on Windows and Linux. It assumes you're using a base installation of Wowza Streaming Engine 4.8.28 and later, which includes the jdk.jcmd Java module with the JRE that ships with the installer. The same user that owns the Java process running Wowza Streaming Engine must run all commands.
The default location for Java heap dump files created with the jcmd tool is the Wowza Streaming Engine [install-dir]/bin directory. You can provide an absolute path to save the heap dump in a different location.
Switch between the Windows and Linux tabs to select the method that fits your use case.
Windows
On Windows, the SYSTEM account owns the java.exe processes running Wowza Streaming Engine.
- Open an elevated command prompt.
- To get the process ID (PID) for the java.exe process on Windows, open the Task Manager.
- In the Task Manager, go to the Details tab.
- Find the java.exe processes.
- Note the PID for the java.exe process with the higher memory usage.
- Navigate to the C:\Program Files\Wowza Media Systems\Wowza Streaming Engine 4.9.1+2\jre\bin directory.
- Run the following command with the [pid] value from step 5:
jcmd [pid] GC.heap_dump [heap-output-path]/heapdump.hprof
The [heap-output-path] is an optional path to a writeable directory where you can save the heap dump.
Linux
On Linux, the root user owns the com.wowza.wms.bootstrap.Bootstrap Java process running Wowza Streaming Engine.
- Open a terminal window.
- Navigate to the /usr/local/WowzaStreamingEngine-4.9.1+2/jre/bin directory.
- Find the process ID for the com.wowza.wms.bootstrap.Bootstrap Java process:
sudo ./jcmd
- Run the following command with the [pid] value from step 3:
sudo ./jcmd [pid] GC.heap_dump [heap-output-path]/heapdump.hprof
The [heap-output-path] is an optional path to a writeable directory where you can save the heap dump.
Create a Java heap dump using the Wowza Streaming Engine REST API
This method can be used with Wowza Streaming Engine 4.5.0.01 and later.
Note:
- To get started with the Wowza Streaming Engine REST API, see articles in the Overview section.
- If the server is not responding, these instructions may not work. We recommend using the jcmd method to create the heap dump instead.
To create a heap dump, use the following request:
curl -X PUT --header 'Accept:application/json; charset=utf-8' --header 'Content-type:application/json; charset=utf-8' http://127.0.0.1:8087/v2/servers/{serverName}/actions/heapDump
This writes the heap dump to [install-dir]/WowzaStreamingEngine_HeapDump_${epoch}.hprof. The ${epoch} variable is replaced with the current system epoch in milliseconds.
You can change the location of the heap dump by including the filename query parameter in the request. For example, to write the heap dump to C:\Temp, use the following request:
curl -X PUT --header 'Accept:application/json; charset=utf-8' --header 'Content-type:application/json; charset=utf-8' http://127.0.0.1:8087/v2/servers/{serverName}/actions/heapDump?filename="C:\Temp\WowzaStreamingEngine_HeapDump_${epoch}.hprof"
Create a Java heap dump using JConsole
Use this method for Wowza Streaming Engine 4.4.1 and earlier.
- Use JConsole/JMX to connect to the running Wowza Streaming Engine.
- On the MBeans tab, in the com.sun.management/HotSpotDiagnostics object, select the Operation section.
- In dumpHeap parameters, enter the following information:
p0: [heap-output-path] p1: true - do a garbage collection before dump heap
For example:
p0: c:/dump.dmp p1: true
- Click the dumpHeap button.
Create a Java heap dump using jHat
To use this method, Wowza Streaming Engine must be running the Java JDK, which includes the Java Heap Analysis Tool (jHat) tool.
- Open a command prompt and "change directory" to the bin folder of the JDK installation.
- Use operating system tools such as ps (ps -ef on Linux or the Task Manager on Windows) to find the process ID of the Java process that's running Wowza Streaming Engine.
- Execute the following command:
jmap -dump:format=b,file=c:\Temp\heapdump.hprof [pid]
Where [pid] is the process ID of the process running Wowza Streaming Engine.
Create a Java heap dump automatically when an OutOfMemory error is thrown
You can configure Java to create a heap dump whenever an OutOfMemory error occurs.
Open the [install-dir]/conf/Tune.xml file in a text editor, and then uncomment the following line:
For Linux:
<VMOption>-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${com.wowza.wms.AppHome}/logs</VMOption>
For Windows:
<VMOption>-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="${com.wowza.wms.AppHome}/logs"</VMOption>
Save the file and then restart Wowza Streaming Engine.
Note: To force a garbage collection cycle before creating a heap dump, run the command jcmd [pid] GC.run.