OutOfMemoryException

Hello,

I have an external JAR and I must call his main. This JAR has to encrypt a file.

But if the file is too big, the main returns an OutOfMemoryException.

I know the "-Xms256m" and "-Xmx512m" but if I call the main like this :

PrepareImportFile pif = new PrepareImportFile();

String[] args = {fileSource, fileCrypt, "-f", "keyp.txt", "-Xms256m", "-Xmx512m"); pif.main(args);

it doesn't work.

It is normal because -Xms256m -Xmx512m are applied to the JVM.

But I don't find a solution.

Is it possible to grow up the memory allocated to the JVM into the java code ?

I thank you for your help.

[661 byte] By [kryptona] at [2007-11-27 2:10:55]
# 1
The -Xms parameters are for the JVM not the main method.You could call the external jar as a process: look at the Runtime class.What i would do is replicate the main method that is in the jar if you don't have the source then look at decompiling it with jad.
ChristopherAngela at 2007-7-12 2:03:38 > top of Java-index,Java Essentials,Java Programming...
# 2
As another thought you could also call these parameters on your jvm.
ChristopherAngela at 2007-7-12 2:03:38 > top of Java-index,Java Essentials,Java Programming...
# 3

Thanks for your answer.

I can't use sources of this jar. This is a bought component and I have not to decompile it.

How coud you proceed using a new thread ? I thought threads were only used for "light" tasks. And how this solution can help me ?

"you could also call these parameters on your jvm."

Is this possible to dinamically modify these parameters ? My application will be deploy and I can't tell to all user to modify these parameters.

Thanks for your help.

kryptona at 2007-7-12 2:03:38 > top of Java-index,Java Essentials,Java Programming...
# 4
If the encryption process is running out of memory then it is very very very badly written. I can encrypt GByte files without running out of memory.
sabre150a at 2007-7-12 2:03:38 > top of Java-index,Java Essentials,Java Programming...
# 5
Yes. Just 1 Mo caused the OutOfMermoryException... but I can't decide and I must use it.
kryptona at 2007-7-12 2:03:38 > top of Java-index,Java Essentials,Java Programming...
# 6

> Yes. Just 1 Mo caused the OutOfMermoryException...

> but I can't decide and I must use it.

Says who! Presumably some idiot manager. If so then tell him what he can do with his pp code. You have to learn to put managers in their place. They should not be involved in technical decisions unless they have have the expertise and most don't. Ask your manager why the rubbish encryption code has to be used.

sabre150a at 2007-7-12 2:03:38 > top of Java-index,Java Essentials,Java Programming...
# 7

That's not very important because he's not in the in the firm yet.

I deduct this is not possible directly. I wanted to change memory parameters into the code.

If I use the thread solution, is this possible to put a parameter somewhere in the JAR file in order to double click only on the JAR file ?

I don't want to create a bat with a command line.

Thanks.

kryptona at 2007-7-12 2:03:38 > top of Java-index,Java Essentials,Java Programming...