Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2005

Tip: Looking for answers? Try searching our database.

memory and class loading

Thread view: 
sriram_kosuri@yahoo.com - 22 Sep 2005 11:10 GMT
hi,

1. I got (say 100) java class files.
2. In each there are 1000 "final static String" are defined.
3. Only one\few variable from each of these classes is referred in the
main class.
4. Classloader loads all these class files into memory, because there
is reference in main.

Just because I refer to one variable the whole class file is being
loaded.

Comments about memory usage?

rgds
-Sri
Roedy Green - 22 Sep 2005 11:47 GMT
On 22 Sep 2005 03:10:45 -0700, sriram_kosuri@yahoo.com wrote or quoted

>Just because I refer to one variable the whole class file is being
>loaded.

the static variables will be, but the methods are not necessarily
hooked up or jitted until they are used.

I think though they will be interned, so that if you have the same
string in many classes, there will be only one copy of the string.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Thomas Hawtin - 22 Sep 2005 19:23 GMT
> 1. I got (say 100) java class files.
> 2. In each there are 1000 "final static String" are defined.
[quoted text clipped - 7 lines]
>
> Comments about memory usage?

If you make the static final Strings initialisers compile time
expressions (for instance just a literal String), then the value should
be placed into the referring class at compile time.

But I'd be tempted to change the design.

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.