IBM Support

Improper coding of a GatewayScript processing action might cause memory consumption and an "Out of Memory" condition

Troubleshooting


Problem

In a GatewayScript processing action, typical memory consumption is caused by object creation. In extreme cases of improper coding in a GatewayScript action, the DataPower appliance might run out of memory, reload, and generate a backtrace and an error report.

Symptom

A transaction that is in an infinite loop and that is allocating memory with each loop iteration can cause the appliance to run out of memory. The free memory on the appliance decreases, and the appliance eventually reloads.

Cause


In a GatewayScript processing action, typical memory consumption is caused by object creation. An improperly coded script might endlessly consume memory as shown by this example:
   
var a = [];
   for (var i = 0; len; i++) {
       a.push("this is an infinite loop and keeps populating data into an array");
   }


In this example, the "for" loop consumes memory by populating data into an array object, and the loop never ends. Eventually, the appliance runs out of memory, and the system restarts.

Environment

All DataPower services that use one or more GatewayScript processing actions.

Diagnosing The Problem

When a GatewayScript processing action runs for a long period of time and then the DataPower appliance reloads, the system log might contain an 'emergency' log message such as the following message:

tid(#): The file location at local:///<your-gws-script.js> caused a fatal error: Allocation failed - process out of memory

The likely cause of the error message and the appliance reload is that an excessive amount of memory was allocated by the GatewayScript program.

Resolving The Problem

To avoid this issue in a production environment, run any new or changed code in a test environment first. In test, investigate if there are any abnormal memory decreases or long-running GatewayScript processing actions.

If you do encounter the error, carefully examine the GatewayScript file that is mentioned in the log message. One tool that can help you is the GatewayScript debugger. Add a "debugger;" statement to your script, enable the debugger on the processing action that references your script, and step through the lines of code, looking for infinite loops and large memory allocations.

[{"Product":{"code":"SS9H2Y","label":"IBM DataPower Gateway"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"--","Platform":[{"code":"PF009","label":"Firmware"}],"Version":"7.0.0","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
15 June 2018

UID

swg21674117