433 views

Description

Instantiating GlideScriptable abstract classes in Helsinki causes a memory leak. One place this occurs is in the base system script include named "Cart," where there is an instantiation of one of these classes (GildeappQuestion). Caching these classes seems to be a change in behavior from pre-Helsinki Rhino.

Note: This is not isolated to the GlideappQuestion class.

Symptoms experienced:
- Nodes are running out of free memory or are high on memory
- Scripts are instantiating GlideappQuestion objects (see example code snippet in the steps to reproduce)

Steps to Reproduce

 

  1. Navigate to System Definition > Script Includes.
  2. Search for and open the Cart script include.
  3. See the code snippet below for an example of instantiating GlideappQuestion (which is an example of a GlideScriptable abstract class)

    Example problematic code:

    var question = new GlideappQuestion(gr.sys_id); ----> instantiating GlideappQuestion
    var variable = new GlideRecord('sc_item_option');
    variable.initialize();
    variable.value.setValue(question.getValue());

    If/when this script is run, it consumes memory that is never garbage collected causing a memory leak.

These reproduction steps specifically do not direct you to run this script (or one similar to it) as it will lead to an out of memory on the node. This is most commonly seen in the base system Cart script include (used in the steps to reproduce above), but is not limited to Cart. If this specific code has been copied elsewhere in custom scripts, the issue occurs. This code existed in pre-Helsinki builds, but is handled differently with the new Rhino, therefore causing the memory issues.

Note: This class is used elsewhere in the following scripts: CatalogUIPolicyBuilder and ExpertUIPolicyBuilder. In these scripts, we use static methods on GlideappQuestion without instantiating it (not using the keyword "new") so the same memory leak is not present.

Workaround

Relief Actions:

To provide relief on a node that is affected by this memory leak, restart the node.  Additionally, upgrade to a build where this is fixed:

HP3, HP4: Theses builds have a "partial" fix such that the "Cart" Script Include will no longer cause this memory leak.  This Script Include is the only OOB place where this issue can occur.  If there are custom scripts where these objects are being instantiated they will need to be manually addressed.

HP5+, Istanbul: These builds have the complete fix.  The platform will no longer be leaking memory when GlideScriptable abstract class are instantiated.

Preventative Actions:

To provide permanent relief and prevent the issue from coming back, remove the lines where the object is being instantiated. In most cases, if not all, this will be in the Cart script include and any custom scripts where this code has been copied:

Current:

var question = new GlideappQuestion(gr.sys_id); ----> instantiating GlideappQuestion
var variable = new GlideRecord('sc_item_option');
variable.initialize();
variable.value.setValue(question.getValue());

After the workaround is in place:

var variable = new GlideRecord('sc_item_option');
variable.initialize();
variable.value.setValue(null);
variable.item_option_new = gr.sys_id;

Note: We are passing a "null" value into the setValue() method as "question.getValue()" always returns null in the original script.


Related Problem: PRB697208

Seen In

Eureka Patch 13 Hot Fix 2
Helsinki Patch 0 Hot Fix 1
Helsinki Patch 0 Hot Fix 3
Helsinki Patch 1
Helsinki Patch 1 Hot Fix 1
Helsinki Patch 2
Helsinki Patch 2 Hot Fix 2
Helsinki Patch 3

Fixed In

Helsinki Patch 3
Helsinki Patch 4
Istanbul

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2017-10-10 16:48:39
Published:2016-08-03