I use an automatically generated Java class to execute a special method. Because of this, I have to refer to the method by reflection.
This execution is initiated by the Swing Thread because the method (called from the unknown class) updates the UI element. Each execution of a new thread searches for a method in the class by calling
Class { ... public Method[] getMethods() throws SecurityException ... }
Logic getMethods, caches an element, but I do not know why. The profiler shows me that obeycts methods are floating in memory.
I can disable the Java caching method by setting the system property sun.reflect.noCaches, but my application became incredibly slow after I changed this property.
Question: I could implement my own caching algorithm before trying to get the method from the class. But the project I'm working on is very large, and we have several reflection challenges.
What can solve this problem?
What cirumstances can cause a memory leak (wrong classloader, ...)?
The project runs on Linux using Java 1.5
source share