Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
RmiServiceExporter class-loader and allocation issue [SPR-11562] #16186
Calling services exposed through spring RmiServiceExporter seem to be causing some weired class-loader issue. It seems RMIClassLoader ends up repeatedly trying to load the class, accessing the jar files also causing major allocation pressure.
I found out about this as I ran 'Java Flight Recorder' on a production server that is heavy on RMI. Using JFR's allocation profiling I found the issue. As I tried to narrow it down I found surprisingly that running a native java RMI code performing the same operation do not cause such allocation or classloader access the jar.
The attached archives contains a project that exposes identical services through both version. Two client is also provided to access each type of exported service. There is also an attachment containing the JFR recording from a run involving 1M call to each version of the service. You can open the recording with 'Java Mission Control' that comes with Jdk7.
Native RMI - < 400ms, ~50M allocation
While the performance comparison cannot be made directly since the RmiServiceExporter uses reflection, the allocation is frightening since most of it is around classloading and not directly in reflection/spring code. My assumption is that Spring's use of proxy & reflection is somehow confusing the RMIClassloader.
Affects: 3.2.8, 4.0.2
Tahseen Mohammad commented
Has there been any progress on this issue. I would at least love to know if this is a Spring issue or JVM or some third party library, so that I can pursue other avenue if appropriate. I am also willing to help in diagnosing or narrow down the problem if someone can guide me. My knowledge of proxy and classloader is fairly limited though.
More than a fix, I need to know whether its feasible to wait for a fix or simply move the code from Spring RMI to plain java RMI.