Sometimes, when adding a very large number of classes (typically over 10,000-15,000), you may see an exception thrown in the proxy generator. The exception may manifest itself in a variety of ways; for example, as a System.NullReferenceException or a java.lang.ClassNotFoundException.
The likely cause of the problem is that the Java side ran out of space in the "permanent generation heap." This is a special heap distinct from the regular object heap that holds reflection-related information including class and method objects. Increasing the regular object heap memory allocation will not fix this problem, but increasing the permanent generation heap memory allocation will. To do so, you must change the operation of the proxy generator so that the Java side is not started automatically by the proxy generation tool, but must be started manually by the user. (Please see details of how to do this in the Users' Guide in the subsection "Starting Java manually" inside the section on proxy generation.) When starting the Java side, supply the following command-line option:
Note that this is the standard way of changing the MaxPermSize in the Sun JRE. For other vendors' JREs, please see the vendor-specific documentation.