loading classes with different classloaders to unload them from the JVM when not needed


In my application i'm using ServiceLoader to load modules(classes from .jar file) with different ClassLoaders in order to completely unload them when not needed from the context of the application and from the JVM itself. I know maybe is not a common topic "unload classes from JVM", there are some conditions for that to happen, so i am making the necessary effort. To make sure if all is working like expected i'm tracing the load and unload of classes with -XX:+TraceClassLoading and -XX:+TraceClassUnloading, the info from this parameters shows me that i can do a complete unload of any module from mi app and from the JVM itself (unload from the JVM happens during a complete GC). All this seems to work fine... but my question is why the .jar files from where the module classes was loaded are keep open by the JVM?, that .jars cant be removed but the JVM says to have unloaded the classes from them. Obviously this is during JVM execution, but why keep open that .jar files if the JVM has no class loaded from them?, there is any thing i can do to force the JVM to free that .jar files?


Issue of the class load / unload should be deeply explored within different web containers.

Some googling shows up that Tomcat 6.x has option antiJARLocking that option is used in Tomcat sources at <a href="http://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/" rel="nofollow">http://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/</a>

Please read the sources and you will get sample of load / unload code there.


  • HTTP error on adding large data using jquery ajax
  • Application Insights Live Metrics with ASP.Net MVC and Web Api
  • Ax Trace Parser Doesnt Show SQL Queries
  • HttpWebRequest takes a long time to send when there are a bunch at once from client
  • No source code is available for type did you forget to inherit a required module?
  • Audit log in Cassandra 2.2.8 community edition
  • measure elapsed time, amount of memory and cpu used by the extern program
  • httpmessagehandler - reading content
  • Detect Windows processes start and exit events with C# without WMI
  • Stack Walk on linux using ptrace
  • client and server cannot communicate, because they do not possess a common algorithm - SSLStream
  • Does CGImageRelease() free UIImage's memory?
  • JAX-WS RI: Best way to implement a Method Interceptor
  • Is there any API for the command vmmap
  • submit button to contingent pages [duplicate]
  • How to run a single row of a Cucumber scenario outline example table in RubyMine?
  • Upgrade from Jenkins Weekly to LTS
  • Is it ok to submit a build to the app store for testing when a previous build is waiting for review?
  • where is chrome CSS Reference
  • Can't run Appium tests on iOS 10 on real device
  • How to protect the mp3 file from read or copy on Android?
  • OAuth and the YouTube API
  • Adding directive inside the directive programatically
  • Ionic storage “get” returns null only on the second call within method
  • sweetalert2 inputoptions from file in select example
  • New Firebase failed: First argument must be a valid firebase URL and the path can't contain “.”
  • JSON encode and decode on PHP
  • Building Qt project for C++11 standard
  • How to pass nginx proxy url for socket
  • Yii2: Config params vs. const/define
  • How to rebase a series of branches?
  • NetLogo BehaviorSpace - Measure runs using reporters
  • Spring security and special characters
  • JSON with duplicate key names losing information when parsed
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Matrix multiplication with MKL
  • C# - Getting references of reference
  • Hits per day in Google Big Query
  • File not found error Google Drive API
  • Converting MP3 duration time