Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

how to increase jvm heap size in jdk1.5.0

Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am getting java.lang.OutOfMemoryError: Java heap space Exception ,

when running below java class in eclipse editor by configuring JVM of JDK1.5.0 within eclipse (or at command prompt) on windows platform

by using below class I am merging two Index Directories(one is 1.87 GB of size and other one is 522 MB of size) into new one using Lucene API
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.index.IndexWriter;
public class MergeIndex {

private MergeIndex (){

public static void main(String arg[]) throws InvalidDocDBXMLFormatException {


}catch(Exception e){


public static void mergeIndexes() {

try {
System.out.println("before add indexwriter");
IndexWriter writerDisk = new IndexWriter(FSDirectory.getDirectory(new File("D:\\DocServerData\\MergedIndexes\\DocDB1_Category1_Index"), true),new StandardAnalyzer(),true);
long l1 = System.currentTimeMillis();
System.out.println("before addIndexes method>>>>"+l1);
writerDisk.addIndexes(new Directory[]{FSDirectory.getDirectory(new File("E:\\1lac-7mar\\DocDB1_Category1_Index"), false),FSDirectory.getDirectory(new File("E:\\2lacs-19feb\\DocDB1_Category1_Index"), false)}) ;
long l2 = System.currentTimeMillis();
System.out.println("before Optimize method>>>"+ (l2-l1));
System.out.println("after Optimize method"+System.currentTimeMillis());
System.out.println("after add indexwriter");
}catch(Exception e){
System.out.println("Exception Occured>>>>>>" +e);


below is snapshot of my java class

Call tree (all threads together)
Name Time (ms)
All Threads
831,735 100 %
MergeIndex .main(String[])
831,563 100 %
171 0 %

Generated by YourKit Java Profiler 6.0.12 Mar 9, 2007 10:34:49 AM

It would be appreacited if any body tell me how to increase JAva heap size
in jvm on windows paltform
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
run your java class with command line :
java -Xmx1G [class]

this code set maximum heap 1 Giga
Posts: 6663
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again. Not SCJP
Java Cowboy
Posts: 16084
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You already asked the same question, have a look at the answers there.
He does not suffer fools gladly. But this tiny ad does:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!