I am in the process of creating a java application that will be running for long periods of time which requires updated functionality without shutting down. I\'ve decided to
You seem to be using the application's default classloader to load the compiled classes - that makes it impossible for the classes to be garbage collected.
So you have to create a separate classloader for your freshly compiled classes. This is how app servers do it.
However, even if you use a separate classloader for your compiled classes, it can be tricky to get those classes to be picked up by garbage collection, because the classloader and all the classes it loaded are not eligible for garbage collcetion as long as a single instance of any of those classes is referred to anywhere else (i.e. the rest of your application).
This is known as a classloader leak and a common problem with appservers, causing redeployments to use ever more memory and eventually fail. Diagnosing and fixing a classloader leak can be very tricky; the article has all the details.