wood burning stoves 2.0*
The moose likes Java in General and the fly likes Deleting a class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Deleting a class" Watch "Deleting a class" New topic
Author

Deleting a class

Mohamed Jeleel
Greenhorn

Joined: Mar 22, 2010
Posts: 18
Hi All,

I want to know in java can we delete a class loaded in to memory.

for example I have a login module. After user logs in I want to delete all the login module related classes its members etc... from the memory.
Because those classes will not need after that.

tx
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

ClassLoader do that for you.
Mohamed Jeleel
Greenhorn

Joined: Mar 22, 2010
Posts: 18
I am not clear.
Pushkar Choudhary
Rancher

Joined: May 21, 2006
Posts: 425

code killer wrote:

Please edit your first and last name to use a real name. Obviously fictitious names are not allowed at Javaranch. Read this for more details.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19544
    
  16

If you use a new class loader to load the classes, the classes loaded using this class loader will be unloaded when the class loader is garbage collected. This does require you to remove all other references to these classes, including references to instances.

URLClassLoader is used most often.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Technical issues aside, why are you trying to do this? It's unlikely the memory savings you see will be significant, or even register, in the great scheme of Java memory usage.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Deleting a class
 
Similar Threads
Help in JSP + menus
java thin client login in Websphere
New JavaRanch Journal article: Authentication using JAAS
How do i get handle to httpServletRequest in my custom login module
servlet and jdbc (urgent)