| Author |
Where are loaded classes cached
|
Ondrej Homola
Greenhorn
Joined: Jul 14, 2010
Posts: 2
|
|
Hi,
I have this small problem with class loading:
When I run a java program, with classpath to a remote jar on a really slow network, it takes a while to load the classes (that is okay).
But if I run the same program again just seconds after, the classes will be loaded immediately. Does that mean, the classes are cached on a disk in the java's cache directory?
Strangely it only works, if I re-run the application until 20 seconds or so. Which also makes it difficult to search for the cached classes on the disk to prove my thought.
I did some network data profiling though. Only the first (slow) run actually downloads the classes from the remote disk.
If there really is some class caching, could anyone point me to some documentation on it?
Thanks a lot.
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16811
|
|
It's highly unlikely that this has anything to do with the JVM caching classes, and more likely... it's related to the OS doing file caching.
Many network file systems, NFS, SMB, etc., support some type of change detection and file caching.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32830
|
|
And welcome to the Ranch
|
 |
Ondrej Homola
Greenhorn
Joined: Jul 14, 2010
Posts: 2
|
|
Thanks for reply, okay I would happily accept that as an explanation, but ...
A program like this ... :
... causes the file to be loaded via the network evey time, so the caching doesn't take place. Shouldn't the OS cache both the File and the .jar in the same way?
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
|
|
|
http://faq.javaranch.com/java/AvailableDoesntDoWhatYouThinkItDoes
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12952
|
|
Ondrej Homola wrote:... causes the file to be loaded via the network evey time, so the caching doesn't take place. Shouldn't the OS cache both the File and the .jar in the same way?
I guess that files on the network will not be cached in memory by the operating system, because (unlike files on the local harddisk) the operating system does not have full control over them - some other computer may change the file anytime.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
 |
|
|
subject: Where are loaded classes cached
|
|
|