is there any way to limit maximum virtual memory usage of javac? When running java, I can run it with "-XmxAm" (where A is number of free megabytes) to limit it. Is there anything for javac like that? Thanks.
Description. The javac command reads source files that contain module, package and type declarations written in the Java programming language, and compiles them into class files that run on the Java Virtual Machine. The javac command can also process annotations in Java source files and classes.
Technically, javac is the program that translates Java code into bytecode (. class file) - an intermediate format which is understandable by the Java Virtual Machine (JVM). And java is the program that starts the JVM, which in turn, loads the . class file, verifies the bytecode and executes it.
If you set the -sourcepath option, the compiler searches the indicated path for source files; otherwise the compiler searches the user class path for both class files and source files.
You use the -source option to specify the java version used for compilation and you use the -target option to specify the lowest java version to support. eg. If I specify a target of 1.4, then my program will not be able to run on java 1.3 or lower. see the following javac documentation for more info.
You can give the same runtime options to javac (and most java programs with an own native starter) by using -J
options. By convention, all such options are passed directly to the runtime system. So, in your case, you can invoke
javac -J-Xmx5m -J-Xmx4m <source>
to run javac with very little memory. Of course, as reseter said, it is of limited use this way, since javac may really need some amount of memory to compile. On really big projects, you may want to increase the memory this way, though.
I don't think so. The compiler will need to build a full syntax tree, etc, in order to work, so limiting its memory usage wouldn't be the best of ideas.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With