| 1 October 2008 |
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!


2 comments to 'Quick view at the memory usage of your Java Application'
2 October 2008
Hi, I just want to point out that from JDeveloper you can also run Memory and CPU profilers against your running ADF applications as well.
The profilers are included with the tool at no cost and are really useful for tracing performance issues within the application.
Juan.
3 October 2008
Hi Juan,
Thanks for pointing that out. I must say the first time I used JConsole, I wasn’t using JDeveloper for development. So next time I run into some issue and I am using JDev, I will surely give it a look.