Results 1 to 5 of 5
- 04-23-2010, 08:57 AM #1
Member
- Join Date
- Apr 2010
- Posts
- 12
- Rep Power
- 0
How to unload previous class when it has loaded
Hi everyone,
I have a issue about JVM.
I have loaded my class file,when I don't use this class,I want to unload this class from JVM,as don't let this class to inside JVM al l the time,or sometimes I fix my class,so I have t o reload to replace my originality class.
can anyone help me.
- 04-24-2010, 01:01 AM #2
I don't believe it is possible to have a class unloaded. it is possible to have a class re loaded, such as a new version of the class, as tomcat and other servlet containers do for you when you redeploy the .war file or recompile the .class files. Also, considering how JSP pages are transcoded into .java files and automatically compiled into .class files. These also get replaced, but never really completely remove the previous class image, in the permanent generation, or permgen space. It is possible to use JVM arguments to tune the percentage of heap size allocated to permanent generation (e.g. loaded classes), but eventually, after (re)loading enough classses the permgen space runs out and the vm needs to be rebooted.
so (I think) the only way to have a class unloaded is to have the underlying java vm restarted ??
- 04-24-2010, 03:36 AM #3
Member
- Join Date
- Apr 2010
- Posts
- 12
- Rep Power
- 0
- 04-26-2010, 04:05 PM #4
Member
- Join Date
- Apr 2010
- Posts
- 8
- Rep Power
- 0
IMHO a class is unloaded if no object of this class exists and the classloader of the class is unloaded itself. I guess OSGi works exactly this way. But I'm not sure so the best idea to see how it works is to check out the OSGi base project and have a look on the classloading mechanism.
Anyway, I would recommend to use OSGi for such requirements.
- 04-26-2010, 05:36 PM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
Have a look at Java Rebel; it's not free but you can get an evaluation version (I downloaded it once) and it's fun. Basically it's a class loader that checks for new file images of the classes it already loaded; if it finds a newer image and there is nothing using the code and data in that particular class (this is the most important part) it reloads the class.
kind regards,
Jos
Similar Threads
-
calling the servelet code when the page is loaded
By shivakumari in forum Java ServletReplies: 1Last Post: 04-01-2009, 11:39 AM -
Storing image loaded in applet in mysql database
By mrvigneshmca in forum Java AppletsReplies: 1Last Post: 03-20-2009, 04:17 PM -
Getting the host from where the Applet was loaded
By Java Tip in forum Java TipReplies: 0Last Post: 02-15-2008, 08:41 AM -
How to get the type of the loaded JDBC driver.
By shankar in forum JDBCReplies: 1Last Post: 08-08-2007, 02:42 PM -
newbie: the app is loaded but i can't see it
By tamayo in forum New To JavaReplies: 1Last Post: 07-21-2007, 08:14 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks