• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

how to recognize and eliminate the unnecessary libraries

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I would like to know if associating to a java application more libraries than necessary, the useless ones are still associated with the .war file and they needlessly consume memory.

If this is true, there is a way to recognize the libraries that although part of the project in practice are never invoked, so that they can be eliminated from the project?

thanks
 
Marshal
Posts: 80637
471
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure about .war files, but a .jar file only contains what you have included. Try going through the import statements. For each import which is not a standard class in the Oracle API, you will need to include a .jar somewhere. If all your imports are from your own classes or the standard API, you do not need to include anything. Only your own classes.
Remember that redundant or unnecessary files in the .jar simply occupy space on the hard drive and are never used, so they do no harm.
 
Saloon Keeper
Posts: 28661
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's a sticky problem.

There are tools that can trace static dependencies, but it's virtually impossible to track dynamic dependencies.

If you are using Maven to build your WAR, there are tools that can at least determine what jars claim other jars as dependencies, and I'm presuming that other tools such as Ant/Ivy may have similar capabilities.

Knowing jar dependencies isn't as fine-grained as knowing actual class dependencies, but it's good enough for most purposes.

As far as overhead goes, there may be some RAM consumed/cached for the indexes of classes not loaded, but it's not likely to be a major component of the overall memory usage.
 
Campbell Ritchie
Marshal
Posts: 80637
471
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Beginning to sound too difficult for this forum: moving discussion.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic