inspector





This option was added in Profound.js version 5.2.0.

This option is not valid on Windows.

When this option is set to true, signal handlers will be added to the server that can be used to trigger heap snapshots and CPU profiles using Node's Inspector API. 

To send signals to the server process, you must first find the server process id. The process id is output to the server's standard output log on startup. Signals can be sent using the kill command from a shell. If running on IBM i, run the command from a PASE shell.

Example - Heap Snapshot

Running a heap snapshot dumps the contents of Node's V8 heap for later inspection. This can be useful for troubleshooting memory leaks or excessive memory use. Running a heap snapshot can take a minute or more, depending on the size of the heap. The Node.js event loop will be blocked while the snapshot runs, meaning that the server will be unable to respond to any requests until the snapshot completes. Taking a heap snapshot requires memory twice the size of the heap at the time of the snapshot. If there is not enough memory available, the server process may be killed by the operating system.

To trigger a heap snapshot, send the SIGHUP signal to the server process:

Trigger Heap Snapshot
kill -HUP <PROCESS_ID>

When a heap snapshot is started, the server outputs the following message to the standard output log:

Starting heap snapshot.

Heap snapshots are written to INSTALLATION_DIRECTORY/profiler-reports/profoundjs.heapsnapshot. Any previous snapshot is overwritten. When the process completes, the server will output the following message to the standard output log:

Heap snapshot written to INSTALLATION_DIRECTORY/profiler-reports/profoundjs.heapsnapshot

The server will output messages to the standard error log if there are any problems that prevent the heap snapshot from running.

Heap snapshots can be viewed in Chrome Developer Tools.

Example - CPU Profiler

Running the CPU profiler collects data on CPU usage. This can be useful for troubleshooting high CPU usage or long-running processes. The CPU profiler must be started and allowed to run while the server processes requests, and then ended in order to produce a report. 

To start the CPU profiler, send the SIGUSR1 signal to the server process:

Start CPU Profiler

When the CPU profiler is started, the server outputs the following message to the standard output log:

After allowing the server to process the requests that you want to collect data for, end the CPU profiler by sending the SIGUSR2 signal to the server process:

End CPU Profiler

CPU profiles are written to INSTALLATION_DIRECTORY/profiler-reports/profoundjs.cpuprofile. Any previous profile is overwritten. When the process completes, the server will output the following messages to the standard output log:

The server will output messages to the standard error log if there are any problems that prevent the CPU profiler from running.

CPU profiles can be viewed in Chrome Developer Tools.

Click here for information on how to modify this setting.