Question

We were doing performance testing of one of our legacy application when we found that no of classes loaded continously increasing which led to increase of the non heap memory.

Now I was looking for the rootcauses,One thing I could think of is that at several places we are using Class.forName like below:

Test a = (Test) Class.forName(className, false, Test.class.getClassLoader()).newInstance();

Can this be a reason ? If classname is same in the above code statement,does calling class.forName loads same class again and again.

Application server :Jboss 6.1 EAP

JDK :1.6.27

Was it helpful?

Solution

Since, the classloader would be same, it will not load the class again & again. The same class can be reloaded again only if you have multiple classloader loading the classes at different point of time.

Every classloader, first checks if the class its about to load is already loaded or not. If its not loaded then only it will load it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top