Sometimes you might want to get a quick impression of the memory usage of your Java application, or more specific, of your Oracle ADF application that is running on OC4J. There are a lot of tools (profilers) available to let you investigate this to a very detailed level. But most of the times these programs cost money and/or they are quite hard to work with (it takes some hours/ days to understand them). I am not saying these programs are not good, on the contrary, these programs will help you if you run into serious memory/threading issues with your software. But with this post I am aiming at the general Java developer that wishes to have a impression of the memory footprint of his application.
With JDK 1.5 there is a tool available called ‘jconsole‘. This tool is rather easy to understand and easy to use. If you want to use the tool for your ADF application that is running on a local OC4J instance you have to edit the startup script of OC4J. You can add a parameter to the JVMARGS variable like this:
set JVMARGS=%OC4J_JVM_ARGS% -Dcom.sun.management.jmxremote
Now when you have started the OC4J instance with the script you can start JConsole in another console with:
$JDK_HOME/bin/jconsole.exe
This will start the graphical tool. Now connect to the one active session and voila! Here is an example of the connection window:

A lot of information about threads and memory usages of your OC4J process is available. You can now play around in the OC4J admin window to start and stop the ADF application and see the results in the JConsole window. Here is a screen dump of the Heap size:

Just make sure you are using JDK1.5 or later!