On Mar 14, 5:06 pm, Rock <rocco.ro...@gmail.com> wrote: > proxy = __import__(name) # where name is a string > proxy.doOperation(*args) > > After leaving the method where the above two lines of code are > located, the module stored in proxy is no longer accessible, and the > resources are released. That's cool because, even better than the > namespace, you don't clutter your memory with unused modules. We've > got around 50 agents at the moment, but we don't need to have them > loaded in memory at the same time, but only on demand obviously.
The following might point into the direction you need. ;; simple function to get a fresh classloader (defn make-fresh-classloader [] (proxy [java.lang.ClassLoader] [])) ;; Global var, since we want something bindable (def *my-classloader*) ;; Use a fresh classloader in a binding-form (binding [*my-classloader* (make-fresh-classloader)] (comment Your code, in which the classes you want to be disposed later should be loaded via the fresh classloader, not via the system classloader)) Assuming you leak neither newly allocated Class-objects nor instances thereof outside the binding-block, the created classloader will be GCd (along with classes loaded by it) sometime after the binding-block has been executed (allocated Classe-objects retain a reference to their classloader, so leaking them would prevent the classloader from being GCd). --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---