You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Ravi <ra...@siti.com> on 2006/02/07 04:34:07 UTC

Memory Increasing when the optimize is called

Hi 

 

 

I have index file around 2GB and when I optimize the index file tomcat is
taking more memory than normal and even after completion of optimization
also it is still taking more memory than the normal memory.. is this way it
will happen or do I need to change any thing to  reduce the memory I am
sending the code for optimization .. Please tell me is there any wrong in
the following code.

 

 

 

 

public  static  void optimizeIndexing() {

                         System.out.println("Index Optitmaization
started....");

                         ERMProperties objProperties
=          new ERMProperties();

                                    String strApplicationDataPath
=          objProperties.getProperty("applicationDataPath");

                                    String strIndexPath
=          strApplicationDataPath + "Index";

                                    File objIndexDir
=          new File(strIndexPath);

                                    boolean bNewIndex
=          false;

                                    IndexWriter indexWriter
=          null;

                                    FSDirectory objFSDirectory
=          null;

                                    try{

                                                if
(!objIndexDir.isDirectory()) {

 
objIndexDir.mkdir();

                                                            bNewIndex
=          true;

                                                }

                                                objFSDirectory
=          FSDirectory.getDirectory(new File(strIndexPath), bNewIndex);

                                                indexWriter
=          new IndexWriter(objFSDirectory, new HLAnalyzer(), bNewIndex);

                                                indexWriter.optimize();

                                    }catch(Exception objException){

                                        objException.printStackTrace();

                                    }finally{

                                                try { if (indexWriter !=
null) indexWriter.close(); } catch( Exception exc) { }

                                                try { if (objFSDirectory !=
null) objFSDirectory.close(); } catch( Exception exc) { }

                                    }

                            

                                    System.out.println("Index Optitmaization
Endeded....");

                        }

 

 

Regards,

Ravi Kumar Jaladanki