My Java application runs another Java application, by running the process "java -jar j.jar". J.jar is known to use a LOT of memory depending on the dataset it is given, and often gets an OutOfMemoryError heap. So I want to use -Xmx on it, so that I can allocate as much memory as possible (or close to). I was thinking of getting the total memory on the system, then specifying 80-90% of that in -Xmx.
Is there any solution to my problem? And, how does my solution sound?
Edit: I cant reduce the memory consumption as the memory being used is by Java's built=in pack200 compression, which I am using to pack some JAR files.