• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Will the Resource Bundle object loads property file into memory?

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I have a basic doubt about the resource bundle object. I wanted to know if the creation of ResoureBundle object loads the entire property file or will it just create the pointer to file and every request to a key will do an I/O operation?
I think that the file gets loaded into memory(Please correct if I am wrong). In that case I feel that use of too many property files reduces the performance of the application.
I hope my concern is clear.
Waiting for all of your response.
Thanks,
Mrutyunjay
[ June 20, 2002: Message edited by: Mrutyunjay Hanchinal ]
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had the same doubt last year when I was working on Internationalisation of a CRM product.
Considering issues like frequent IO/file-reads (so not many small files) and efficient memory management (so no ONE single large file), I ended up suggesting with module level .properties files. (That was not the best option, I should say now.) That is one resource bundle per module of the product. That also helped us to manage module wise licenses efficiently.
Also another issue with a property file serving more than one class is, it becomes increasingly tedious for developers and will end up with duplicate keys!
Anyway, let the discussion continue...
Ashok.
 
Mrutyunjay Hanchinal
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks Ashok for your reply.
It appears from the reply of Ashok that the key value pairs in property file get loaded on to memory and hence it is not an I/O or File read operation instead it is burden on the memory.
Is this understanding correct?
Please suggest
Thanks,
Mrutyunjay
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All the properties get loaded into memory. It is just like loading a class file.
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you call ResourceBundle.getBundle("foo") several times, it caches what bundle it gave you and you get the same thing every time. So there is little extra cost for calling getBundle several times to retrieve the same bundle (you don't need to cache it yourself).
When ResourceBundle loads a properties file, the entire file is loaded when it is created using Properties.load().
Forums like this are a good place to get answers, but don't forget that the JDK comes with java source (in src.jar). So you can always check up on us by looking at the source yourself
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic