Z-JAVA-105 - Java exception java.lang.OutOfMemoryError

Before we are able to make an exact diagnosis of the problem, we would require to know the following:

  • Are you receiving this error message from the JobScheduler application itself or from one of the jobs being run by JobScheduler?
  • Can you provide a scheduler.log file in which we can see where the error occurs?
  • How does JobScheduler behave after this error occurs?

Problem Java heap space

We are getting the following error message:

 Z-JAVA-105 Java exception java.lang.OutOfMemoryError("Java heap space"), method=spooler_process()Z

Unfortunately we have not been able change the value with "-Xmx" as we have not been able to localise the part of the application in which the memory overflow occurs.

Solution Java heap space

However, there are two situations where it is possible that you can avoid this error by increasing the heap space yourself:

  • If your problem is occurring in a job, you can use the java_options attribute to increase the heap space at the job level. It would, however, be interesting for us to know whether this error occurs with one of the jobs the SOS GmbH has provided or whether it occurs with a custom job?

Problem unable to create new native thread

We are getting the following error message:

 Z-JAVA-105 Java exception java.lang.OutOfMemoryError("unable to create new native thread"), method=spooler_process()Z []

This error can occur if an api job in a job chain gets orders without a break.
Then the task of the job never ends and throws above error after an unspecified number of orders.
This is a very special situation. Until the corresponding ticket http://www.sos-berlin.com/jira/browse/JS-1123 is unresolved you can use the following workaround.

Workaround unable to create new native thread

Copy the file force_new_task.js from force_new_task.zip to the folder where the api job is stored and configure the job with the following monitor-script and a parameter "max_num_of_orders_per_task":

<job  order="yes" stop_on_error="no">
    <params >
        <param  name="max_num_of_orders_per_task" value="10"/>
    </params>

    <script .../>

    <monitor  name="forceNewTask" ordering="1">
        <script  language="javax.script:rhino">
            <include  live_file="force_new_task.js"/>
        </script>
    </monitor>

    <run_time />
</job>

This script ends the current task after the max. number of orders which is set in the above parameter.
The next order creates a new task.