This question is a result of the answers provided to me for my previous question.
I was asked to use Eclipse MAT to investigate what is eating up my heap. Below are my observations (Top Consumers):
class sun.awt.SunToolkit 333.7 MB
com.tennisearth.service.impl.CacheManagerServiceImpl 136 MB
org.apache.jasper.servlet.JspServlet 91.5 MB
I have already fixed the issue with CacheManageServiceImpl
, but require help with SunToolkit
.
Below is the code that creates an Image object (which internally uses SunToolkit.imgCache
)
Image img = new ImageIcon(imagePath).getImage();
int imageWidth = img.getWidth(null);
int imageHeight = img.getHeight(null);
Plz note that the Image object is only being created to get the width / height of the image which is required later in some logic.
Is there a way to disable SunToolkit
image caching? Better yet, is there a way to clear this cache? Or is there a better way I can retrieve this information?
BTW for your reference, I am using the below command to run jboss (plz note the heap size arguments):
java -Dprogram.name=run.sh -server -Xms256m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=256m -verbose:gc -Xloggc:/data1/logs/jboss/GC.log -XX:+HeapDumpOnOutOfMemoryError -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dorg.apache.catalina.STRICT_SERVLET_COMPLIANCE=false -Djava.net.preferIPv4Stack=true -Djava.library.path=/usr/local/java/jboss-4.2.2.GA/bin/native -Djava.endorsed.dirs=/usr/local/java/jboss-4.2.2.GA/lib/endorsed -classpath /usr/local/java/jboss-4.2.2.GA/bin/run.jar:/usr/local/java/jdk1.6.0_06/lib/tools.jar org.jboss.Main -c default -b <IP_ADDRESS> -Djboss.messaging.ServerPeerID=1
Sumit