Monday, March 17, 2014

How to perform Remote Memory Profiling for ADF Application


Performing memory profiling for ADF applications is a very important step that we usually miss during our ADF Application development life cycle.  We can find potential bottle necks inside our application like query getting lots of unrequired rows, lots of unwanted objects instance lying around and not getting clean up etc.

There are lots of memory profilers in the market. The most useful memory profiler w.r.t to ADF applications is the default memory profiler that comes with jdev installation. This gives us  a top down view (i.e from ADF to java ) of memory then a bottom up view that other memory profilers give us.

Approach:

The way we did memory profiling for our application
  • Deploy the application EAR pointing to something close to real time DB/OID on the intergrated weblogic. Try and make it as close as real time. 
  • Enabling the Intergrated weblogic for remote memory profiling on a specific port.
  • Start the jdev memory profiler client on the same port .
Steps for enabling Intergrated weblogic for remote memory profiling
Step 1
Edit File : C:\jdev_work\system11.1.1.5.37.60.13\DefaultDomain\bin\startWeblogic.cmd
Copy the below two lines before
-----------------------------------------------
set REMOTE_DEBUG_JAVA_OPTIONS=-Xdebug -Xnoagent -agentpath:C:\Oracle\Middleware\jdeveloper\jdev\lib\profiler16.dll=jarpath=C:\Oracle\Middleware\jdeveloper\jdev\lib\profiler-agent.jar,enable=m,startup=connect  -agentlib:profiler16=port=4000,jarpath=C:\Oracle\Middleware\jdeveloper\jdev\lib\profiler-agent.jar,startup=connect,mem
set JAVA_OPTIONS=%SAVE_JAVA_OPTIONS% %REMOTE_DEBUG_JAVA_OPTIONS%
-----------------------------------------------
set SAVE_JAVA_OPTIONS=


Step 2
When you start the weblogic server, you will see something like this in the logs.

Starting WLS with line:
C:\Oracle\MIDDLE~1\JDK160~1\bin\java -client   -Xms256m -Xmx512m -XX:CompileThreshold=8000 -XX:PermSize=128m  -XX:MaxPermSize=512m -Dweblogic.Name=DefaultServer -Djava.security.policy=C:\Oracle\MIDDLE~1\WLSERV~1.3\server\lib\weblogic.policy -agentlib:jdwp=transport=dt_socket,server=y,address=52702 -Djavax.net.ssl.trustStore=C:\Oracle\Middleware\wlserver_10.3\server\lib\DemoTrust.jks -Djbo.debugoutput=console -Dweblogic.nodemanager.ServiceEnabled=true  -Xverify:none  -da -Dplatform.home=C:\Oracle\MIDDLE~1\WLSERV~1.3 -Dwls.home=C:\Oracle\MIDDLE~1\WLSERV~1.3\server -Dweblogic.home=C:\Oracle\MIDDLE~1\WLSERV~1.3\server  -Djps.app.credential.overwrite.allowed=true -Dcommon.components.home=C:\Oracle\MIDDLE~1\ORACLE~1 -Djrf.version=11.1.1 -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger -Ddomain.home=C:\JDEV_W~1\SYSTEM~1.13\DEFAUL~1 -Djrockit.optfile=C:\Oracle\MIDDLE~1\ORACLE~1\modules\oracle.jrf_11.1.1\jrocket_optfile.txt -Doracle.server.config.dir=C:\JDEV_W~1\SYSTEM~1.13\DEFAUL~1\config\FMWCON~1\servers\DefaultServer -Doracle.domain.config.dir=C:\JDEV_W~1\SYSTEM~1.13\DEFAUL~1\config\FMWCON~1  -Digf.arisidbeans.carmlloc=C:\JDEV_W~1\SYSTEM~1.13\DEFAUL~1\config\FMWCON~1\carml  -Digf.arisidstack.home=C:\JDEV_W~1\SYSTEM~1.13\DEFAUL~1\config\FMWCON~1\arisidprovider -Doracle.security.jps.config=C:\JDEV_W~1\SYSTEM~1.13\DEFAUL~1\config\fmwconfig\jps-config.xml -Doracle.deployed.app.dir=C:\JDEV_W~1\SYSTEM~1.13\DEFAUL~1\servers\DefaultServer\tmp\_WL_user -Doracle.deployed.app.ext=\- -Dweblogic.alternateTypesDirectory=C:\Oracle\MIDDLE~1\ORACLE~1\modules\oracle.ossoiap_11.1.1,C:\Oracle\MIDDLE~1\ORACLE~1\modules\oracle.oamprovider_11.1.1 -Djava.protocol.handler.pkgs=oracle.mds.net.protocol  -Dweblogic.jdbc.remoteEnabled=false -Dwsm.repository.path=C:\JDEV_W~1\SYSTEM~1.13\DEFAUL~1\oracle\store\gmds   -Dweblogic.management.discover=true  -Dwlw.iterativeDev= -Dwlw.testConsole= -Dwlw.logErrorsToConsole= -Dweblogic.ext.dirs=C:\Oracle\MIDDLE~1\patch_wls1035\profiles\default\sysext_manifest_classpath;C:\Oracle\MIDDLE~1\patch_jdev1111\profiles\default\sysext_manifest_classpath -Xdebug -Xnoagent -agentpath:C:\Oracle\Middleware\jdeveloper\jdev\lib\profiler16.dll=jarpath=C:\Oracle\Middleware\jdeveloper\jdev\lib\profiler-agent.jar,enable=m,startup=connect  -agentlib:profiler16=port=4000,jarpath=C:\Oracle\Middleware\jdeveloper\jdev\lib\profiler-agent.jar,startup=connect,mem  weblogic.Server
Agent_Onload
Agent_Onload
Listening for transport dt_socket at address: 52702
Debugger connected to local process.
Profiler 11.1.1.5381 (090522.0635)for JDK 1.6
Profiler waiting for connection on port 4000


 

Step 3 :


Start the profiler agent
Select the view controller, which you want to profile,
Click Run->Attach to -> Memory Profilee,
For Remote profiling, select the 2nd option "Attach to Remote Process " and give the host details.  Leave the port number to 4000, as the profiler agent runs on port number 4000.


Step 4
Once the profiler is started, you should see the continuiton of the weblogic logs as
Profiler connected
 
Step 5
Simply open the browser and login, you can see the memory profiling parameters in the profiler window.


Happy Memory Profiling !!!!!

1 comment:

Md Jahangir Pasha said...

great job !!! Well define approach even newbie can easily understand