Results 1 to 3 of 3
  1. #1
    nin888 is offline Member
    Join Date
    Nov 2011
    Posts
    3
    Rep Power
    0

    Default outOfMemoryException run bat file to increase heap space?

    Hello. I have a program that runs out of heap space and throws a outOfMemoryException. I can fix it by typing in command prompt:
    cd c:\directory\
    java -Xmx128m programName

    where 128m is the increase necessary. though i need to run my program from command prompt and i want it to be fixed when i run my program automatically. so i created a batch file that runs in main before anything else, but i don't know what to put in the batch file to get the same effect. the code in main to open the batch file is:
    try{
    System.out.println("Start Running the batch file");
    Runtime.getRuntime().exec("heapIncrease.bat");
    System.out.println("Completed");
    }
    catch (Exception e){
    e.printStackTrace();
    }

    I know the batch file works because I tested "CALL notepad" inside and it opened notepad and then the rest of the main method executed, but i want the batch file to increase heap space to 128m (or whatever) so that i can run my program with higher values and never have to open command prompt or do anything manually beyond running my program.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,759
    Rep Power
    7

    Default Re: outOfMemoryException run bat file to increase heap space?

    Huh?

    You want a Java program to run a bach file to run a Java program?

    Huh?

    Just place that java command into a batch file and double click it. If you want it to run at a certain time then setup a scheduled task.

  3. #3
    nin888 is offline Member
    Join Date
    Nov 2011
    Posts
    3
    Rep Power
    0

    Default Re: outOfMemoryException run bat file to increase heap space?

    i don't know how to do that. I don't know the commands for a batch file. how do i do the same thing i did with command prompt with a batch file? my only idea of how to auto fix a heap space error is to run a batch file out of my program that does the same thing as what i would type into command prompt. that way when i run the program the computer goes ahead and changes the heap space on it's own and then the rest of the program runs.

Similar Threads

  1. How to handle heap space?
    By Enthiran in forum New To Java
    Replies: 5
    Last Post: 12-16-2010, 03:00 PM
  2. Java Heap Space
    By a.r.viswanath@gmail.com in forum Eclipse
    Replies: 2
    Last Post: 07-02-2010, 05:34 AM
  3. no heap space... need more heap
    By anupam.kumar in forum Advanced Java
    Replies: 3
    Last Post: 02-08-2010, 04:42 PM
  4. Heap Space Problem
    By segolas in forum Advanced Java
    Replies: 6
    Last Post: 01-14-2010, 11:29 AM
  5. Java heap space?
    By javanewbie in forum New To Java
    Replies: 1
    Last Post: 06-24-2008, 06:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •