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

Why do I receive the error message: java.lang.OutOfMemoryError when running an SDK application in C#.NET?

Why do I receive the error message: java.lang.OutOfMemoryError when running an SDK application in C#.NET?

Problem:

Why do I receive the error message: java.lang.OutOfMemoryError when running an SDK application in C#.NET?

Resolution:


  • Product Name: CaliberRM
  • Product Version: 2005 R2, 2005 R2SP1
  • Product Component: SDK

This indicates that the Java Heap Size may not be large enough and your application is running out of memory. The Java Heap Size needs to be increased. See sample code below which shows how to increase the Java Heap Size. (The sections of code highlighted in red set the Java Heap Size).

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");
}

}
}
}

The call to set the Java Heap size must be made before the initial call to the CaliberRM SDK, otherwise it will not be set and will just use the default size.


Old KB# 15809

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:25
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.