Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

What techniques are available to avoid a "java.lang.OutOfMemoryError" when running an SDK application?

What techniques are available to avoid a "java.lang.OutOfMemoryError" when running an SDK application?

Problem:

What techniques are available to avoid a "java.lang.OutOfMemoryError" when running an SDK application?

Resolution:


 

  • Product Name: CaliberRM
  • Product Version: All
  • Product Component: SDK


The java.lang.OutOfMemoryError occurs because there is not enough Java Heap Space to store the information contained in the CaliberRM Project Objects. There are 2 methods to resolve the error message: java.lang.OutOfMemoryError when running an SDK:

  1. Increase the Java Heap Space available to the application. The following code can be used to increase the java heap space

 

using System;
using System.Windows.Forms;
using Starbase.CaliberRM.Interop;

namespace SDKCode_VS2005
{
public partial class Form2 : Form
{

//Set up objects
CaliberServerFactory myFactory = new CaliberServerFactory();
CaliberServer myServer;
Project myProject;
Session mySession;

Initializer objInitializer = new Initializer();
IStJavaVMInfo objStJavaVMInfo;

public Form2()
{
InitializeComponent();
}
private void doLogin_Click(object sender, EventArgs e)
{
//Set Memory Usage (in this example, setting it to 400 mb)

objStJavaVMInfo = objInitializer.JavaConfiguration.CurrentJavaVM;
objStJavaVMInfo.Options = "-Xmx400m";


try
{
//get server info

myServer = myFactory.Create("localhost");

//get username and password and attempt to login

mySession = myServer.login("admin", "admin");

System.Console.WriteLine("Logged In");

int no_projects;

//count number of Projects
no_projects = mySession.Projects.Count;

//List all projects
for (int i = 0; i 
{
myProject = (Project)mySession.Projects;
System.Console.WriteLine("Project: " + myProject.Name);
}
}
catch
{
System.Console.WriteLine("Login Failed");
}

}
}
}

 

2 Obtain a single CaliberRM Project or a SubSet of CaliberRM Projects from the CaliberRM database. This method can return a single CaliberRM Project Object, therefore reducing the amount of information required to be stored

Attached to the KB article is sample code that will return all projects from the CaliberRM Server one project at a time. This code uses the FrameworkManager class available in the Java SDK. Below is an explanation of the java code and the techniques used to obtain a single Project Object.

Code Snippet


 

Related documents

?

 

Old KB# 16530

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 18:35
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.