title: OSGI with Custom Class Loader Perm Gen Issue
body: <p>For our purposes we didn't go with the standard OSGI jar reference that builds the jars into the bundle.  Rather for online upgrades, we wanted to be able to provide new and updated jars during upgrades.  Within our Activator class which starts and stops a bundle, we Implement our own URLClassLoader and then lookup all jars in a sub folder and supply to the URLClassLoader along with the OSGI CLassLoader as the parent.  This is great because now admins of the application can simply add jars to a classpath and restart the application(osgi restart, not actually shutting down jvm).  We got this working great.  Plus our bundle.jar doesn't get huge over time as all of the jar references are not included in the bundle jar.</p>
  
  <p>However, now we have the ability to remotely restart the application using OSGI to do it within the same JVM.  However when the restart occurs, the class loader we added never gets garbage collected.  So if you restart the application like 10 times then it will blow the Perm Gen out of memory(Java 1.7).  </p>
  
  <p>We have tried to mimic what apache WebAppClassLoader does on unload but this didn't remove the references either.</p>
  
  <p>I have scoured the internet for solutions to this and granted we are coding outside the typical OSGI implementation however is there not a way to clear the references to the ClassLoader.  After restart there honestly shouldn't be any references.</p>
  
  <p>We have used MAT to analyze the heap dump but the referenced list of classes is always different.</p>
  
  <p>Anyone know of a way to load external libraries a better way for use within OSGI?</p>
  
  <p>Thanks for any information!</p>