Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

Memory problem on Intralink scripting

bemwv

New member
Hi,


I need to make a lot of export from Intralink. The files I need to export to disk are all listed into a text file.

I have first recorded a macro that export one file, then I modified this macro to create a loop that read into my text file and

export the items 500 by 500.


This is working well but there is a memory problem: I can see in the task manager that the process javaw.exe is consuming more and

more memory until the whole process crash.

I need to find a way tor release the consumed memory betwwen each iteration of my loop.


I've tried to add the line "IL=null",

I also tried to force a call to the java garbage collector: Runtime r = Runtime.getRuntime(); then r.gc()


But without success.

I noticed that when I start my script step my step, in the "watch" tab I didn't see the instructions I added (IL=null; and r.gc()).


Here is my script:
<br style="font-family: Courier New,Courier,mono;">import java.io.*;<br style="font-family: Courier New,Courier,mono;">import com.ptc.intralink.client.script.*;<br style="font-family: Courier New,Courier,mono;">import com.ptc.intralink.script.*;<br style="font-family: Courier New,Courier,mono;">import java.lang.Object;<br style="font-family: Courier New,Courier,mono;">import java.lang.Runtime;<br style="font-family: Courier New,Courier,mono;"><br style="font-family: Courier New,Courier,mono;">public class Export_IL extends ILIntralinkScript { <br style="font-family: Courier New,Courier,mono;"> <br style="font-family: Courier New,Courier,mono;"><br style="font-family: Courier New,Courier,mono;"> private void ProcessIL(String FileList)<br style="font-family: Courier New,Courier,mono;"> {<br style="font-family: Courier New,Courier,mono;"> ILIntralinkScriptInterface IL = (ILIntralinkScriptInterface)getScriptInterface(); <br style="font-family: Courier New,Courier,mono;"> Object[] FilterName = new Object[]{FileList};<br style="font-family: Courier New,Courier,mono;"> Object[] FilterRevision = new Object[]{""};<br style="font-family: Courier New,Courier,mono;"> Object[] FilterVersion = new Object[]{new java.lang.Integer(0) };<br style="font-family: Courier New,Courier,mono;"> IL.openWindow( "Locate", "", "" ); <br style="font-family: Courier New,Courier,mono;"> IL.setCurrentViewer( "Locate" ); <br style="font-family: Courier New,Courier,mono;"> IL.select( "Par nom", "System" ); <br style="font-family: Courier New,Courier,mono;"> IL.clearFilter( ); <br style="font-family: Courier New,Courier,mono;"> IL.addFilter( "Name", "=", FilterName ); <br style="font-family: Courier New,Courier,mono;"> IL.addFilter( "Revision", "Latest", FilterRevision); <br style="font-family: Courier New,Courier,mono;"> IL.addFilter( "Version", "Latest", FilterVersion);<br style="font-family: Courier New,Courier,mono;"> IL.applyFilter( ); <br style="font-family: Courier New,Courier,mono;"> IL.selectAll( "PIV" ); <br style="font-family: Courier New,Courier,mono;"> IL.openWindow( "CheckOut", "", "" ); <br style="font-family: Courier New,Courier,mono;"> IL.setCurrentViewer( "PIV" ); <br style="font-family: Courier New,Courier,mono;"> IL.updateDependents( "None", "latest", 18 ); <br style="font-family: Courier New,Courier,mono;"> IL.startEditor( false );<br style="font-family: Courier New,Courier,mono;"> IL.setCheckoutMethod( true );<br style="font-family: Courier New,Courier,mono;"> IL.setTargetWorkspace( "export1" );<br style="font-family: Courier New,Courier,mono;"> IL.checkout( );<br style="font-family: Courier New,Courier,mono;"> IL.closeWindow( );<br style="font-family: Courier New,Courier,mono;"> IL.closeWindow( );<br style="font-family: Courier New,Courier,mono;"> IL.selectAll( "WSPI" );<br style="font-family: Courier New,Courier,mono;"> IL.openWindow( "Export to Disk", "", "" );<br style="font-family: Courier New,Courier,mono;"> IL.selectExportDependency( "None" );<br style="font-family: Courier New,Courier,mono;"> IL.selectExportFolder( "C:\\export\\export1" );<br style="font-family: Courier New,Courier,mono;"> try<br style="font-family: Courier New,Courier,mono;"> { <br style="font-family: Courier New,Courier,mono;"> IL.ok( );<br style="font-family: Courier New,Courier,mono;"> }<br style="font-family: Courier New,Courier,mono;"> catch(Exception e)<br style="font-family: Courier New,Courier,mono;"> {<br style="font-family: Courier New,Courier,mono;"> IL.cancel();<br style="font-family: Courier New,Courier,mono;"> }<br style="font-family: Courier New,Courier,mono;"> IL.deleteWorkspace( "export1" );<br style="font-family: Courier New,Courier,mono;"> IL.createWorkspace( "export1", "" );<br style="font-family: Courier New,Courier,mono;"> IL.openWindow( "Workspace", "export1", null );<br style="font-family: Courier New,Courier,mono;"> IL.selectTree( "FTWS", "export1" );<br style="font-family: Courier New,Courier,mono;"> IL.setCurrentViewer( "WSObjects" ); <br style="font-family: Courier New,Courier,mono;"> IL = null;<br style="font-family: Courier New,Courier,mono;"> FilterName = null;<br style="font-family: Courier New,Courier,mono;"> FilterRevision = null;<br style="font-family: Courier New,Courier,mono;"> FilterVersion = null; <br style="font-family: Courier New,Courier,mono;"> }<br style="font-family: Courier New,Courier,mono;"><br style="font-family: Courier New,Courier,mono;"> public void run() throws Exception {<br style="font-family: Courier New,Courier,mono;"> {<br style="font-family: Courier New,Courier,mono;"> File file = new File("c:\\export\\Liste.txt");<br style="font-family: Courier New,Courier,mono;"> BufferedReader reader = null;<br style="font-family: Courier New,Courier,mono;"> String FilesToFound = null;<br style="font-family: Courier New,Courier,mono;"> int Nb = 0;<br style="font-family: Courier New,Courier,mono;"> Runtime r = Runtime.getRuntime();<br style="font-family: Courier New,Courier,mono;"> <br style="font-family: Courier New,Courier,mono;"> try<br style="font-family: Courier New,Courier,mono;"> {<br style="font-family: Courier New,Courier,mono;"> reader = new BufferedReader(new FileReader(file));<br style="font-family: Courier New,Courier,mono;"> String text = null;<br style="font-family: Courier New,Courier,mono;"><br style="font-family: Courier New,Courier,mono;"> // repeat until all lines is read<br style="font-family: Courier New,Courier,mono;"> FilesToFound = null;<br style="font-family: Courier New,Courier,mono;"> Nb = 0;<br style="font-family: Courier New,Courier,mono;"> while ((text = reader.readLine()) != null)<br style="font-family: Courier New,Courier,mono;"> { <br style="font-family: Courier New,Courier,mono;"> if (Nb == 0)<br style="font-family: Courier New,Courier,mono;"> {<br style="font-family: Courier New,Courier,mono;"> //FilesToFound = "\""+text+"\""; <br style="font-family: Courier New,Courier,mono;"> FilesToFound = text; <br style="font-family: Courier New,Courier,mono;"> }<br style="font-family: Courier New,Courier,mono;"> else<br style="font-family: Courier New,Courier,mono;"> {<br style="font-family: Courier New,Courier,mono;"> //FilesToFound = FilesToFound+";\""+text+"\"";<br style="font-family: Courier New,Courier,mono;"> FilesToFound = FilesToFound+";"+text;<br style="font-family: Courier New,Courier,mono;"> }<br style="font-family: Courier New,Courier,mono;"> text = null;<br style="font-family: Courier New,Courier,mono;"> Nb++;<br style="font-family: Courier New,Courier,mono;"> if (Nb == 500)<br style="font-family: Courier New,Courier,mono;"> {<br style="font-family: Courier New,Courier,mono;"> Nb = 0;<br style="font-family: Courier New,Courier,mono;"> ProcessIL(FilesToFound);<br style="font-family: Courier New,Courier,mono;"> FilesToFound = null;<br style="font-family: Courier New,Courier,mono;"> r.gc();<br style="font-family: Courier New,Courier,mono;"> <br style="font-family: Courier New,Courier,mono;"> }<br style="font-family: Courier New,Courier,mono;"> }<br style="font-family: Courier New,Courier,mono;"> if (Nb > 0)<br style="font-family: Courier New,Courier,mono;"> {<br style="font-family: Courier New,Courier,mono;"> ProcessIL(FilesToFound); <br style="font-family: Courier New,Courier,mono;"> }<br style="font-family: Courier New,Courier,mono;"> } catch (FileNotFoundException e)<br style="font-family: Courier New,Courier,mono;"> {<br style="font-family: Courier New,Courier,mono;"> e.printStackTrace();<br style="font-family: Courier New,Courier,mono;"> } catch (IOException e)<br style="font-family: Courier New,Courier,mono;"> {<br style="font-family: Courier New,Courier,mono;"> e.printStackTrace();<br style="font-family: Courier New,Courier,mono;"> } finally<br style="font-family: Courier New,Courier,mono;"> {<br style="font-family: Courier New,Courier,mono;"> try<br style="font-family: Courier New,Courier,mono;"> {<br style="font-family: Courier New,Courier,mono;"> if (reader != null)<br style="font-family: Courier New,Courier,mono;"> {<br style="font-family: Courier New,Courier,mono;"> reader.close();<br style="font-family: Courier New,Courier,mono;"> }<br style="font-family: Courier New,Courier,mono;"> } catch (IOException e)<br style="font-family: Courier New,Courier,mono;"> {<br style="font-family: Courier New,Courier,mono;"> e.printStackTrace();<br style="font-family: Courier New,Courier,mono;"> }<br style="font-family: Courier New,Courier,mono;"> }<br style="font-family: Courier New,Courier,mono;"> <br style="font-family: Courier New,Courier,mono;"> <br style="font-family: Courier New,Courier,mono;"><br style="font-family: Courier New,Courier,mono;"> }<br style="font-family: Courier New,Courier,mono;"> }<br style="font-family: Courier New,Courier,mono;">}




Any suggestions ?
 

Sponsor

Articles From 3DCAD World

Back
Top