This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Performance and the fly likes Memory leaks and static variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Performance
Bookmark "Memory leaks and static variables" Watch "Memory leaks and static variables" New topic
Author

Memory leaks and static variables

deepti bellubbi
Greenhorn

Joined: May 06, 2008
Posts: 27

I have been reading up on coding practices that could cause memory leaks and one of them is using static variables or classes,
Since they will remain for lifetime of the application.

Question that comes to my mind is that:- usually when we define a constants file its mostly a class and all the strings are defined as :
public static final String ABC="Constant1";

Now another way of defining the same string as a constant would be to have an interface and within the interface you define

String ABC="Constant1";


Would using an interface to define constants rather than have a class with static definitions make any difference in concerns with memory saving?

Appreciate all your inputs




shivendra tripathi
Ranch Hand

Joined: Aug 26, 2008
Posts: 263
Whenever you define a variable in interface by default it is public static and final. So I don't see any difference in both the cases.


SCJP 1.5(97%) My Blog
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Memory leaks and static variables
 
It's not a secret anymore!