I want to know where the ClassLoader instance is saving, in which memory. Is it saving in heap or in permgen? And if I have a custom ClassLoader( for example JasperReports loads his own ClassLoader which calls JRClassLoader ), instance of it is also saving in heap memory or in permgen?
Asked
Active
Viewed 573 times
1 Answers
2
Classloader is not an exception from the rules, so:
ClassLoader
instance is created on heap,ClassLoader
class is like any other class it is created on permgen (till Java 7)

Crazyjavahacking
- 9,343
- 2
- 31
- 40
-
ok, thanks for answer. Also I want to ask, when the GC is unloading classes from permgen. – Lyudvig Feb 04 '15 at 07:34
-
I think this is not explicitly defined. You can be sore that **classes from permgen will be removed just before the OutOfMemoryException might be thrown**. – Crazyjavahacking Feb 04 '15 at 08:18
-
Not sure what @Crazyjavahacking is talking about in the comment. In theory you could have a custom ClassLoader that uses soft references to it's loaded java.lang.Class:es, which would mean they get garbage collected before OOME in case there are no instances of them or other references to them, or there may be garbage collectors / options that behave this way, but this _should not be assumed to be the case_. – Mattias Jiderhamn Feb 16 '15 at 12:37