Talend: Job Log – Could not reserve enough space for object heap

Background

Running a little job in Talend and getting the error indicated below.

 

Error


Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Error occurred during initialization of VM
Could not reserve enough space for object heap
Job SalesforceToSQLServer ended at 17:16 01/08/2015. [exit code=1]

 

 

What is Heap?

Before we try to diagnose the problem, let us ask ourselves what is stored in the Heap of a Java application.

 

Heap and Stack

In an application, there are a few memory segments, let us concentrate on Heap and Stack, at this time.

Stack

  • Local variables
  • Function call

Heap

  • Objects
    • Objects created through new

 

Memory Errors

When memory is requested and the JVM is unable to satisfy the request, the inadequacy is reflected via error messages.

Thankfully depending on which memory block (Stack or Heap) fails, a distinct error is returned.

Stack

  • java.lang.StackOverFlowError

Heap

  • java.lang.OutofMemoryError

Interpretation

As we are interested in the Database aspect of things, we are a lot more interested in the Heap side of the house.

And, likely the bigger the better.

 

Diagnosis

Let us return back to our “small” problem.

The error is due to the way that our job’s Java JVM arguments is configured:

AdvancedSettings

 

Here is our Job’s JVM arguments current configuration:

Option Value Meaning
 Xms 256M

The -Xms option sets the initial and minimum Java heap size. The Java heap (the “heap”) is the part of the memory where blocks of memory are allocated to objects and freed during garbage collection.

Note that is does not limit the amount of memory that the JVM can use.

 Xmx 1024M

This option sets the maximum Java heap size. The Java heap (the “heap”) is the part of the memory where blocks of memory are allocated to objects and freed during garbage collection. Depending upon the kind of operating system you are running, the maximum value you can set for the Java heap can vary.

Note that is does not limit the amount of memory that the JVM can use.

 

 

 

Remediation

Run 32-bit App, but request 64-bit Java JVM

 

Sign Post:

Based on a comment by AndreV on Stackoverflow – “Maximum heap size for JVM on a 32-bit and 64-bit windows server” ( http://stackoverflow.com/questions/15100737/maximum-heap-size-for-jvm-on-a-32-bit-and-64-bit-windows-server ), we will try using the -d64 option to request 64-bit JVM.

 

Advanced Settings:

So what we did is :

  • Access the “Advanced settings” tab
  • Click on the New button, and the -d64 option

 

AdvancedSettings-64BitJavaJVMRequested

 

Job Output:

 

TryToRun64BitJVMIn32BitApp

 

Error Message:


Error: This java instance does not support a 64-bit JVM

 

In 32 bit, change Max Heap Size (Xmx)

Steps:

Here are the steps we took:

  • Access the “Advanced settings” tab
  • Doubleclick on -Xmx1024M
  • In the Set VM Argument, change the entry from -Xmx1024M to Xmx256M

 

 

JVM Settings – Before

 

AdvancedSettings-Before

 

 

Before

Xmx1024M

 

 

After

Xmx256M

 

JVM Settings – After

JVMSettings - After

 

Output:

Once we clicked the Run button, the Application ran successfully

resultOfChangingXmx1024MTo256M

 

 

32-bit VS 64-bit

Introspection:

In MS Windows, upon Application installation, a lone shortcut is created in the Start menu.  That link launches the 32-bit Application.

A quick way to determine the bitness of a running App, is to look at the Task Manager.

32bit

 

In 64 bit OSes, the Image name column will have a *32 marker to distinguish them.

 

Access 64-bit

The Application is bundled in 32-bit and 64-bit mode.

ExplorerView

 

 

In 64 bit, Keep Max Heap Size (Xmx)

Introduction

Let us play with the 64-bit app by launching TOS_DI-win-x86-64.exe.

In Task Manager, here is what we see:

64bit

 

Quick Explanation:

  • In the Image name column, the 32-bit marker is gone
  • Unfortunately, the memory footprint has been dramatically increased from 315,000 ( 315 MB ) to 900,664K ( 900 MB )

 

Steps

Here are the steps we took:

  • Access the “Advanced settings” tab
  • Doubleclick on -Xmx **** entry
  • In the Set VM Argument, keep/ change the entry at / to -Xmx1024M

 

JVM Settings – Before

JVMSettings - After

 

 

Value – Before

Xmx256M

 

Value

Xmx1024M

 

 

JVM Settings – After

AdvancedSettings-After

 

Job Recreated:

Once we modify the JVM arguments, I will suggest that you save the project.

The application detects the changes, and regenerates the package.

Update Detection:

 

UpdateDetection

 

Building Job:

GenerateJob

 

Output:

Upon clicking the Run button, we were able to validate that the Application ran successfully

resultOfChangingXmx1024MTo256M

 

Summary

There are a few noted ways to right the error stating “Could not reserve enough space for object heap“.

The ways are:

  1. In 32 bit mode:
    • Reduce the maximum requested heap size from the default of 1024 M to 256 M
  2. In 64 bit mode:
    • Keep the requested Heap Size at 1024M

Please keep in mind that 64-bit applications use markedly more memory than 32-bit app.

Having said that 64-bit applications are more reliable, and if your hardware is 64-bit capable, make every effort to run a 64-bit OS.  And, to run 64-bit applications.

 

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s