"Java heap space" Problem

Hi,

I have been told to start a new thread about this error message im getting.

My program is encoding a 23.6mb file.

Every time i run my program on this size of file i get this error message

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

I have tried to increase my memory space but it hasnt had an effect.

This is the command ive used.

java -Xms32m -Xmx512m

[432 byte] By [carrics3a] at [2007-11-27 1:54:29]
# 1
paste code linked to the exception please
calvino_inda at 2007-7-12 1:26:14 > top of Java-index,Java Essentials,Java Programming...
# 2

This is the encoder java file that I have wrote

import java.io.*;

import java.util.*;

public class Encoder

{

public static void main(String [] args)

{

try{

Encoder testy = new Encoder();

DataInputStream In = new DataInputStream(new FileInputStream(args[0]));

DataOutputStream Out = new DataOutputStream(new FileOutputStream(args[1]));

Hashtable<String, Integer> dictionary = new Hashtable<String, Integer>();

//Populate the dicionary with characters

for(int i = 0; i < 256; i++)

{

String valOne = (char)i+"";

int valTwo = i;

dictionary.put(valOne, valTwo);

}

// Do encoding

testy.encode(In, Out, dictionary);

//close the Input file

In.close();

}

catch(IOException e){

e.printStackTrace();

}

}

public void encode(DataInputStream In, DataOutputStream Out, Hashtable<String, Integer> dictionary)throws IOException

{

try{

int dictionarySize= 256;

int reader = 0;

String addVal="";

int writeVal = 0;

String firstVal= (char)In.read()+"";

while(In.available()>0)

{

reader=In.read();

if(dictionary.containsKey(firstVal + (char)reader)){

firstVal = firstVal + (char)reader;

writeVal = dictionary.get(firstVal);

}

else

{

writeVal = dictionary.get(firstVal);

addVal = firstVal + (char)reader+"";

Out.writeShort((short)writeVal);

dictionary.put(addVal, dictionarySize);

dictionarySize++;

firstVal = (char)reader+"";

}

}

Out.writeShort((short)writeVal);

Out.flush();

Out.close();

}

catch(IOException e){

e.printStackTrace();

}

}

}

carrics3a at 2007-7-12 1:26:14 > top of Java-index,Java Essentials,Java Programming...
# 3
what's the line that throws the exception?
calvino_inda at 2007-7-12 1:26:14 > top of Java-index,Java Essentials,Java Programming...
# 4
It doesnt give me a lineThis is what i get back on the command promptC:\Program Files\Java>java Encoder test3.bmp Output.datException in thread "main" java.lang.OutOfMemoryError: Java heap spaceShould increase the memory size?Im not really sure how?
carrics3a at 2007-7-12 1:26:14 > top of Java-index,Java Essentials,Java Programming...
# 5
i'm afraid i can't help you further for such issue :\try to propose dukes on this post maybe it will attract ppl ^^
calvino_inda at 2007-7-12 1:26:14 > top of Java-index,Java Essentials,Java Programming...
# 6
> Should increase the memory size?> Im not really sure how?java -Xmx768m Encoder test3.bmp Output.dat
Airwolfa at 2007-7-12 1:26:14 > top of Java-index,Java Essentials,Java Programming...
# 7
What exactly is the intention of your encoding algorithm? What does it do? Increasing heap size is one thing, but it can't solve everything! Do you really need to store that much information?
Peetzorea at 2007-7-12 1:26:14 > top of Java-index,Java Essentials,Java Programming...