VMware {code} Community
DeepakMishra
Contributor
Contributor
Jump to solution

java.lang.OutOfMemoryError: PermGen space in retrieveServiceContent API

Hi,

In our project we communicate with vCenter/ESX to get the Virtualmachine Details, using java API of VI SDK 4.00.

When we call the API "retrieveServiceContent(serviceInstance)" for the first time in our Application, we frequently get an error:

java.lang.OutOfMemoryError: PermGen space

To avoid this error we have set following jvm parameter

-XX:MaxPermSize=256m

And the error has stopped comming so frequently.

But we will not have the control of deplyment environment (jvm parameters for memory) in production and any memory parameters.

The value in the deployment will be -XX:MaxPermSize=128m

So, can any one please help me in avoiding the error without changing the PermSize.

The code I am using to communicate with VC/ESX is

VimServiceLocator _locator = new VimServiceLocator();

_locator.setMaintainSession(true);

VimPortType _service = _locator.getVimPort(new URL(address));

ManagedObjectReference _svcRef = new ManagedObjectReference();

svcRef.setvalue("ServiceInstance");

_svcRef.setType("ServiceInstance");

ServiceContent _sic = service.*+retrieveServiceContent_+*(_svcRef);

Thank you,

Deepak

Reply
0 Kudos
1 Solution

Accepted Solutions
Steve_Jin
Expert
Expert
Jump to solution

I think it's an issue of Apache. Instead of solving the problem, you want to try the open source VI Java API (see my signature for links). It use much less memory and no memory leak at all. I believe after switching, you won't have this issue unless other part of you app demands too much memory. As a bonus, VI Java is much faster than AXIS.

Steve JIN

Author of VMware VI and vSphere SDK (Prentice Hall)

Creator of open source vSphere (VI) Java API

Blog: DoubleCloud.ORG

Twitter: @sjin2008

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org

View solution in original post

Reply
0 Kudos
1 Reply
Steve_Jin
Expert
Expert
Jump to solution

I think it's an issue of Apache. Instead of solving the problem, you want to try the open source VI Java API (see my signature for links). It use much less memory and no memory leak at all. I believe after switching, you won't have this issue unless other part of you app demands too much memory. As a bonus, VI Java is much faster than AXIS.

Steve JIN

Author of VMware VI and vSphere SDK (Prentice Hall)

Creator of open source vSphere (VI) Java API

Blog: DoubleCloud.ORG

Twitter: @sjin2008

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
Reply
0 Kudos