• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Deleting a class

 
Mohamed Jeleel
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ClassLoader do that for you.
 
Mohamed Jeleel
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not clear.
 
Pushkar Choudhary
Rancher
Posts: 425
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20546
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic