When generating proxies, an OutOfMemoryError: PermGen space is encountered

The problem is that the Java side is running out of memory when you try to load a large jar file. 

There are two ways to handle this:

 

  • You can increase the memory allocations on the Java side.  To do this, you will need to start up the Java side manually, and then run the proxy generator with the "automatically start Java" option turned off.  To start the Java side, see "Starting Java manually" in the Users' Guide.  You can increase the PermGen allocation by using the -XX option, and you may also want to increase the heap allocation using the -Xmx option.  For example:

    java -Xmx512m -XX:MaxPermSize=256m -cp classpath com.jnbridge.jnbcore.JNBMain /props _propsFilePath_

    Once this is done, start up the proxy generator (the GUI version, or the Visual Studio plug-in), select Project–>Java Options…, and uncheck "Start Java automatically."  Make sure you're using tcp/binary, and that the host and port agree with your configuration of the Java side. Now, try loading the jar file.  If you run out of space again, increase the allocation and try again.

  • It also may be the case that you don't need to load the entire jar file.  Instead, place the jar file in the proxy generator's classpath and use the Project–>Add classes from classpath… menu option to add only those classes you want to access directly from .NET, plus their supporting classes.  If you do this, it's quite unlikely that you will run out of memory.  This will probably be the simpler solution and will satisfy most usage scenarios.