User's Guide
PART 3. Java in the Database
CHAPTER 17. Using Java in the Database
This section describes the memory requirements for running Java in the database and how to set up your server to meet those requirements.
Ensure that you allow extra cache for the Java VM In many cases, a cache size of 8 Mb is sufficient. |
The Java VM uses memory on both a per-database and on a per-connection basis.
The per database requirements are not relocatable: they cannot be paged out to disk. They must fit into the server cache. This type of memory is not for the server, it is for each database. When estimating cache requirements, you must sum the requirements for each database you run on the server.
The per-connection requirements are relocatable, but only as a unit. The requirements for one connection are either all in cache, or all in the temporary file.
Java in the database requires memory for several purposes:
When Java is first used when a server is running, the VM is loaded into memory. This requires over 100K of memory, and is part of the database-wide requirements. An additional VM is loaded for each database that uses Java.
For each connection that uses Java, a new instance of the VM is loaded for that connection. The new instance does not require as much memory as the original VM. This is part of the connection-level requirements.
Each class definition is used in a Java application is loaded into memory. This is held in database-wide memory: separate copies are not required for individual connections.
Each connection requires a working set of Java variables and application stack space (used for method arguments and so on).
You can control memory use in the following ways:
Set the overall cache size You must use a cache size sufficient to meet all the requirements for non-relocatable memory.
The cache size is set when the server is started using the -c command-line switch.
In many cases, a cache size of 8 Mb is sufficient.
Set the namespace size The Java namespace size is the maximum size, in bytes, of the per database memory allocation.
You can set this using the JAVA_NAMESPACE_SIZE option. The option is global, and can only be set by a user with DBA authority.
Set the heap size This JAVA_HEAP_SIZE option sets the maximum size, in bytes, of per connection memory.
This option can be set for individual connections, but as it affects the memory available for other users it can be set only by a user with DBA authority.
In addition to setting memory parameters for Java, you can unload the VM when Java is not in use using the STOP JAVA statement. This statement can be executed only by a user with DBA authority. The syntax is simply
STOP JAVA
The VM is loaded whenever a Java operation is carried out. If you wish to explicitly load it in readiness for carrying out Java operations, you can do so by executing the following statement:
START JAVA