VMware Cloud Community
satoshi_goto
Contributor
Contributor

[Self-Solved] Memory leak trouble about SSO auth & sessions of vRO Java REST SDK

We are troubled with memory leak and thread leak about vRO SSO (Single Sign-On) authentications and sessions
while using vRealize Orchestrator Java REST SDK (v7.3).
 
There is nothing clue about this problem in the Internet, we record it here for people have same trouble.
NOTE: We don't use LDAP auth, don't know same problem exists in it.
 
Here is sample code.
 
VcoSessionFactory sessionFactory = new DefaultVcoSessionFactory(vroApiUri);
SsoAuthenticator sso = new SsoAuthenticator(ssoWsdlUri, ssoAdminUri, sessionFactory, lifeTimeSeconds);
SsoAuthentication authentication = sso.createSsoAuthentication(username, password);
VcoSession session = sessionFactory.newSession(authentication);
 
It is works at first.
But it leaks threads and instances after execute above code many time.
 
Our products causes OutOfMemoryError by more than one thousand threads at production.
With jvisualvm, it seems that an instance of SsoAuthenticator creates an instance of ConnectionMonitorThreadBase, it generates Java thread, some Java objects, and so on.
 
We spend several days about solving this problem. Finally, we found the way to avoid OutOfMemoryError.
 
  1. SsoAuthenticator MUST NOT be created more than one.
  2. SsoAuthentication MUST be recreated.
  3. VcoSession#close() MUST call. try-with-resouces may help you.
 
Because:
 
  1. Multi SsoAuthenticator instances causes a thread and heap leaks.
  2. Old SsoAuthentication instance can not expand life time.
  3. It causes memory leaks
 
We don't think it is the best way, because there is no API docs about VcoSession, SsoAuthenticator, and SsoAuthentication.
 
If someone knows the good way, please teach us. 
Reply
0 Kudos
0 Replies