• Post Reply Bookmark Topic Watch Topic
  • New Topic

What is meant by resource leak?  RSS feed

 
senthil sen
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is meant by resource leak?
what is singleton class?where is it used?
 
girish rateshwar
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
well pertaining to "What is singleton class?"
A singleton class is the one which can have only one instance at a time.Its functionality is the same as the SETS in mathematics(Do u remmber the singleton set???)
i have myself never implemented a singleton class.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A resource leak is where memory is being steadily consumed by resources that are no longer being used. This is a major problem in c++ where the programmer is expected to remember to release all resources as they are not longer required.
It can also be a problem in Java if you hang onto references to objects that are no longer required. To avoid this you should remember to set all variables to null as soon as you are finished with the reference. This will allow the gc to free up the memory that the objects were consuming.
 
Nayanjyoti Talukdar
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
As far as Singleton class usage is concerned..I can give u a small example.
Consider this..
U have an application which should load some of the properties at runtime. Assume, same properties can not be used by an another application. Then , we can make the class (which loads all the properties) as singleton so that only one instance at a time is possible.
I think this will help u.
Regards
Nayan.
 
girish rateshwar
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi nayan,
Well this same can also be done by creating a static class?
Well cud u help me with this?
 
Nayanjyoti Talukdar
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I don't think we can make a regular class as static. Only the inner class can be made static. In that case too, u don't need to instantiate the class, u can access all variables and methods since the class is declared static. That way, I think it can't fulfill the requirements of making a single instance of the application.
Regards
Nayan.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!