Runtime compilation uses memory other than that used for the Java object heap. So increasing the heap size (e.g., with -Xmx) won't help the compilation issue, and might even make it worse, if you make the heap so large that the compiler can't get the memory it needs because you've tied it all up in the Java object heap.
What platform (operating system and hardware) are you running? What version of the JRE are you running? What command line parameters are you specifying, and what error message do you get?
platform (operating system and hardware) ?Windows-xp /AMD Athlon 64 processor 3000+
What version of the JRE are you running?Trying on both 1.4.2 and 1.3
What command line parameters are you specifying?- server -Xms256m -Xmx256m
and what error message do you get? java.lang.OutOfMemoryError
If you are compiling a lot of source files with javac, you may well need more than 256MB of memory for the Java object heap. For example, when we build the JDK itself (that's a lot of Java source files), we specify -Xmx512m. You can leave the -Xms256m, as that's the initial size of the heap, so we can grow it if we need to, but won't waste the space if we don't need it.
If this is an invocation of javac (which is what I thought it was), then just putting the -Xmx512m argument on the javac command line should do it. There shouldn't be any "service" involved to restart.
Maybe I'm confused about where you are getting this "OutOfMemoryError while compiling the code". Can you describe what you are doing when you get this error, and maybe even paste the error message to this forum thread?