views:

30

answers:

1

I'm trying to optimize an app that makes a lot of RMI calls. According to JProfiler, more than 30% of the CPU time is spent in the sun.rmi.server.LoaderHandler.urlsToPath() method, which is apparently getting called during marshaling. This method calls URL.toExternalForm()

Is that normal? I haven't yet figured out which objects are getting serialized exactly, but it seems like an odd bottleneck.

What is the purpose of LoadHandler.urlsToPath(), and what can I do to reduce its usage?

A: 

I found this with a Google search for "sun.rmi.server.LoaderHandler.java"

                 /**
0795:             * Convert an array of URL objects into a corresponding string
0796:             * containing a space-separated list of URLs.
0797:             *
0798:             * Note that if the array has zero elements, the return value is
0799:             * null, not the empty string.
0800:             */
0801:            private static String urlsToPath(URL[] urls) {

In simple terms it is String bashing. You'd need to look at the context in which your application is calling this to figure out why it is being called so often, but the chances are that this is a direct consequence of doing lots of RMI calls. If so, the solution will be to do fewer RMI calls, or to use something other than RMI.

Stephen C