aspose file tools*
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 agree. Here's the link: http://aspose.com/file-tools
 
subject: Memory leaks and static variables