Flex SDK includes the mxmlc and compc command-line compilers. You use mxmlc to compile Flex applications from MXML, ActionScript, and other source files. You use the compc compiler to compile component libraries, Runtime Shared Libraries (RSLs), and theme files.
The compilers are located in the sdk_install_dir/bin directory. You configure the compiler options with the flex-config.xml file. The compilers use the Java JRE. As a result, you can also configure settings such as memory allocation and source path with the JVM arguments.
The flex-config.xml file defines the default compiler options for the compc and mxmlc command-line compilers. You can use this file to set options such as debugging, SWF file metadata, and themes to apply to your application. For a complete list of compiler options, see Using mxmlc, the application compiler and Using compc, the component compiler.
The flex-config.xml file is located in the sdk_install_dir/frameworks directory. If you change the location of this file relative to the location of the command-line compilers, you can use the load-config compiler option to point to its new location.
You can also use a local configuration file that overrides the compiler options of the flex-config.xml file. You give this local configuration file the same name as the MXML file, plus -config.xml" and store it in the same directory. When you compile your MXML file, the compiler looks for a local configuration file first, then the flex-config.xml file.
For more information on compiler configuration files, see About configuration files.
The Flex compilers use the Java JRE. Configuring the JVM can result in faster and more efficient compilations. Without a JVM, you cannot use the mxmlc and compc command-line compilers. You can configure JVM settings such as the Java source path, Java library path, and memory settings.
On Windows, you use the compc.exe and mxmlc.exe executable files in the bin directory to compile Flex applications and component libraries. You use the fdb.exe executable file in the bin directory to debug applications. The executable files use the jvm.config file to set JVM arguments. The jvm.config file is in the same directory as the executable files. If you move it or the executable files to another directory, they use their default settings and not the settings defined in the jvm.config file.
The fdb, compc, and mxmlc shell scripts (for UNIX, Linux, or Windows systems running a UNIX-shell emulator such as Cygwin) do not take a configuration file. You set the JVM arguments inside the shell script file.
The location of the jvm.config file depends on which Flex product you use. The following table shows the location and use of the product-specific jvm.config files:
|
Product |
Location of jvm.config |
Description |
|---|---|---|
|
Flex SDK |
sdk_install_dir/bin |
Used by the Java process opened by the mxmlc and compc command-line executable files. |
The most common JVM configuration is to set the size of the Java heap. The Java heap is the amount of memory reserved for the JVM. The actual size of the heap during run time varies as classes are loaded and unloaded. If the heap requires more memory than the maximum amount allocated, performance will suffer as the JVM performs garbage collection to maintain enough free memory for the applications to run.
You can set the initial heap size (or minimum) and the maximum heap size on most JVMs. By providing a larger heap size, you give the JVM more memory with which to defer garbage collection. However, you must not assign all of the system's memory to the Java heap so that other processes can run optimally.
To set the initial heap size on the Sun HotSpot JVM, change the value of the Xms property. To change the maximum heap size, change the value of the Xmx property. The following example sets the initial heap size to 256M and the maximum heap size to 512M:
java.args=-Xms256m -Xmx512m -Dsun.io.useCanonCaches=false
In addition to increasing your JVM's heap size, you can tune the JVM in other ways. Some JVMs provide more granular control over garbage collecting, threading, and logging. For more information, consult your JVM documentation or view the options on the command line. If you are using the Sun HotSpot JVM, for example, you can enter java -X or java -D on the command line to see a list of configuration options.
In many cases, you can also use a different JVM. Benchmark your Flex application and the application server on several different JVMs. Choose the JVM that provides you with the best performance.
Setting the useCanonCaches argument to false is required to support Windows file names.
<?xml version="1.0"?>
<!-- config/ContextRootTest.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="l1.text='url='+s1.url">
<mx:HTTPService id="s1" url="@ContextRoot()/service.jsp"/>
<mx:Label id="l1"/>
</mx:Application>