The program has consumed all available memory, which might occur when dealing with large amounts of data. One way to avoid this error is to make efficient use of the available memory. This can be accomplished by making sure the program does not reserve memory (in the form of arrays, objects, and so on) that is not needed.
Another way to reduce the memory used by a program is to assist the garbage collection routine to dynamically free memory. The garbage collection routine used by JScript takes care of freeing unused memory. The routine frees data that can no longer be accessed by the program. Data may become inaccessible when the data in a variable is replaced with new data or when the scope changes and a variable is no longer accessible.
To free memory in your program, set variables that consume large amounts of memory (such as large arrays or other objects) to null once they are no longer needed. This allows the garbage collector to free the memory.
To correct this error
Make sure that your code uses memory efficiently.
Declare objects that consume large amounts of memory immediately before they are needed.
Set variables to null when they are no longer needed.