Classes from rt.jar loaded by different loaders ? [message #11331] |
Fri, 17 July 2009 06:06  |
Eclipse User |
|
|
|
This is one doubt I got into while analyzing a heap dump. I was trying to
view the classes loaded by the different class loaders, I see that system
class loader has loaded classes like java.util.HashMap etc. Then I
observed another class loader sun.misc.Launcher$AppClassLoader and there
also I see that it has references to classes java.util.HashMap. This has
led me to confusion, I always thought that if system CL is loading classes
like java.util.HashMap, it will not be loaded by any other class loader
since it is the parent CL and a class loaded by a loader can not be loaded
by its child loaders. Can you pls clarify on this please ?
|
|
|
|
|
Re: Classes from rt.jar loaded by different loaders ? [message #11519 is a reply to message #11482] |
Tue, 21 July 2009 13:51  |
Eclipse User |
|
|
|
Hi Satish,
your example will not work this way - the VM knows that your are not
referencing s, v, ss, or the list after the Thread.sleep(). It will
garbage collect those items.
> String s = new String("satish");
> Vector v = new Vector(10);
> ServerSocket ss = new ServerSocket();
> ConcurrentLinkedQueue list = new ConcurrentLinkedQueue();
> System.out.println("TestCL...");
> Thread.sleep(100000000);
Probably all class loaders reference the Vector from the system class
loader.
Take this example: the class loader (not loaded by the system class loader
itself) references a hash table.
Class Name
------------------------------------------------------------ ---------
com.foo.loader.ResourceMultiParentClassLoader @ 0xa8d6338
|- <class> class com.foo.loader.ResourceMultiParentClassLoader @ 0xe38e780
|- parent sun.misc.Launcher$AppClassLoader @ 0xa8c3710
|- package2certs java.util.Hashtable @ 0xa8d63d8
|- classes java.util.Vector @ 0xa8d6400
------------------------------------------------------------ ---------
If you have a question how to interpret a particular view of the Memory
Analyzer, just go ahead and Ctrl-C the selected lines and copy and paste
it to the forum.
Andreas.
|
|
|
Powered by
FUDForum. Page generated in 0.04103 seconds