Skip to Content
author's profile photo Former Member
Former Member

Memory issue using BO XI Enterprise SDK and ISecurityInfo

Hello everybody

I have a big issue using the XIR2 SDK when I want to get rights for an object (universe or overload for example). When I start my process the memory used keep growing, starting for 20 mb to more than 100mb and if I have too many objects, the script hangs. I tried to simplify my code to make it understandable :

My Main Class


			Vector<Integer> vIntOv = OverloadsFactory.getAllOverloadsID();
			Iterator<Integer> itOvIterator = vIntOv.iterator();
			
			Integer cIdOv = null;
			while(itOvIterator.hasNext()) {
				cIdOv = itOvIterator.next();
				System.out.println("ID OV = "+cIdOv);
				
				Overload ov = OverloadsFactory.getOverloadById(cIdOv);
				
				Iterator<PrincipalRestricted> itRestPrin = ov.getPrincipalRestricted().iterator();
				PrincipalRestricted cPrin = null;
				while(itRestPrin.hasNext()) {
					cPrin = itRestPrin.next();
					System.out.println("	REST = "+cPrin.getPrincipalName());
					cPrin = null;
				}
			}

The getOverloadById method in OverloadFactory class :

	public static Overload getOverloadById(int overloadID) throws OverloadException, IOException, ClassNotFoundException, SDKException {
		String name="";
		String creationTime="";
		Vector<RowRestriction> vRestrictedRows = new Vector<RowRestriction>();
		Vector<ObjectRestriction> vRestrictedObjects = new Vector<ObjectRestriction>();
		Vector<PrincipalRestricted> vPrincipalRestricted= new Vector<PrincipalRestricted>();
		
		String boQuery="SELECT * " +
				"FROM CI_APPOBJECTS " +
				"WHERE SI_KIND='OVERLOAD' AND SI_ID="+overloadID;
		
		Iterator<IOverload> itOverload = BoxiRepositoryManager.getInstance().executeQuery(boQuery).iterator();
		
		if(itOverload.hasNext()) {
			IOverload currentIOverload = itOverload.next();
			
			name=currentIOverload.properties().get("SI_NAME").toString();
			creationTime=currentIOverload.properties().get("SI_CREATION_TIME").toString();
			
			//System.out.println("OVERLOAD : "+currentIOverload.getTitle()+" / UNIVERSE : "+UniversesFactory.getUniverseById(currentIOverload.getUniverse()).getName());
			
			Iterator<IRowOverload> itRestrictedRows=currentIOverload.getRestrictedRows().iterator();
			while(itRestrictedRows.hasNext()) {
				IRowOverload currentRestrictedRow = itRestrictedRows.next();
				//System.out.println("	RR ("+currentIOverload.getID()+") Where Clause : "+currentRestrictedRow.getWhereClause());
				vRestrictedRows.add(new RowRestriction(currentRestrictedRow.getRestrictedTableName(), currentRestrictedRow.getWhereClause()));
			}
			
			//System.out.println("	RR ("+currentIOverload.getID()+") Size : "+vRestrictedRows.size());
			
			Iterator<IObjectOverload> itRetsrictedObjects=currentIOverload.getRestrictedObjects().iterator();
			while(itRetsrictedObjects.hasNext()) {
				IObjectOverload currentRestrictedObj = itRetsrictedObjects.next();
				//System.out.println("	RO ("+currentIOverload.getID()+") Object Name : "+currentRestrictedObj.getObjectName());
				vRestrictedObjects.add(new ObjectRestriction(currentRestrictedObj.getObjectID(), currentRestrictedObj.getObjectName()));
			}
			
			Iterator<IObjectPrincipal> itIObjectPrincipal = currentIOverload.getSecurityInfo().getObjectPrincipals().iterator();
			while (itIObjectPrincipal.hasNext()) {
				IObjectPrincipal currentIObjPrincipal = itIObjectPrincipal.next();
				vPrincipalRestricted.add(new PrincipalRestricted(currentIObjPrincipal.getID(),currentIObjPrincipal.getName()));
			}
//			
			itOverload = null;
			
			return new Overload(overloadID,currentIOverload.getUniverse(),name, vRestrictedObjects, vRestrictedRows, vPrincipalRestricted, creationTime);
		} else {
			throw new OverloadException("This Overload ID is not valid");
		}
	}

At the beginning I thought it was a problem in my own code but if you comment the following part in the above method, you'll see that the memory increase will not happen anymore :

Iterator<IObjectPrincipal> itIObjectPrincipal = currentIOverload.getSecurityInfo().getObjectPrincipals().iterator();
			while (itIObjectPrincipal.hasNext()) {
				IObjectPrincipal currentIObjPrincipal = itIObjectPrincipal.next();
				vPrincipalRestricted.add(new PrincipalRestricted(currentIObjPrincipal.getID(),currentIObjPrincipal.getName()));

}

Here the error

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
   at java.util.Hashtable.rehash(Unknown Source)
   at java.util.Hashtable.put(Unknown Source)
   at com.crystaldecisions.sdk.occa.security.internal.a.a(Unknown Source)
   at com.crystaldecisions.sdk.occa.security.internal.f.new(Unknown Source)
   at com.crystaldecisions.sdk.occa.security.internal.a.commit(Unknown Source)
   at com.crystaldecisions.sdk.occa.infostore.internal.ap.a(Unknown Source)
   at com.crystaldecisions.sdk.occa.infostore.internal.ar.if(Unknown Source)
   at com.crystaldecisions.sdk.occa.infostore.internal.ar.getObjectPrincipals(Unknown Source)
   at com.crystaldecisions.sdk.occa.infostore.internal.ar.getObjectPrincipals(Unknown Source)

So it why I think that either there is an issue with "getSecurityInfo()" or I'm using it in a bad way. I tried many things like nulling my objects (even if in java the garbage collector does that by itself), changing my code... but no improvements, it's why I m requesting help from the experts 😊

Thanks to you

PS : sorry for my grammar, i'm french

PS 2 : i just want notify that I'm not a java expert so if you have to criticize my code, no prob 😊

Edited by: Cyril Amsellem on Aug 8, 2008 5:00 PM

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 08, 2008 at 04:56 PM

    Hi Cyril

    It is known that querying the ObjectPrinciples results in very heavy usage of resources. This is why you are seeing the memory spike and I would imagine as well that the script probably takes a bit of time to run.

    Let me see if I can find out any more about that for you.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 11, 2008 at 08:48 AM

    Hi Merry

    Thanks a lot for answering me. I didn't know that "getObjectPrincipal" takes so much memory for running.

    According to you is it normal that the used memory keep growing even after nulling my objects ? For me after requesting the Principales for an object (overload or universe) the memory used should be released. It seems that even after the process an object created in the ISecurityInfo class is still living...

    Thanks again for taking time to help me

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.