• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

resource leakage

 
kotha vijaybabu
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wat is the resource leakage in java
 
Chris Allen
Ranch Hand
Posts: 127
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you be a little more specific with your question? Are you referring to delayed garbage collection?
 
kotha vijaybabu
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no yaar its a interview question actually i dontknow in which perspect it was asked
 
ravi rasa
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

As per my understanding we will use "finally" clause to solve resource leakage.This is related to GC.

Ravi.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kotha vijaybabu:
no yaar its a interview question actually i dontknow in which perspect it was asked

If it's an interview question, then it doesn't belong in the SCJP forum. I'm moving this to the Java in General (Beginner) forum -- please post similar questions there.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Yaar"? Be you a pirate, matey? Be you interviewing fer a piratin' position?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can have resource leakage if you do not properly close resources in your application after using them. For example, in a JDBC program, you should always properly close result sets and statement objects, because if you don't your program will run into problems after running a while.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Resource leak just means grabbing some resource (memory is probably most common) and never giving it back. This:

will rapidly use all the memory you have. That one is real obvious. Collections, especially referenced by static variables, are often the culprits in memory leaks. Some of the others mentioned above, like failing to close a connection, are far less obvious.

The finally clause is a good tip, too. Look how dangerous this is:

If the exception happens the "release" line is skipped. Oops. Moving release to a finally clause helps make sure the release is always done:

Study up on the life-span of objects ... local variables, member variables, thread-locals, statics. Make sure the objects you make will eventually be freed up for garbage collection. Pay attention to exceptions and the APIs for libraries like JDBC which should document places to take extra care.
[ February 02, 2006: Message edited by: Stan James ]
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ernest Friedman-Hill:
"Yaar"? Be you a pirate, matey? Be you interviewing fer a piratin' position?


yaar
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So "yaar" means something like "pal" in English?
 
Vishwas Hegde
Ranch Hand
Posts: 212
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

So "yaar" means something like "pal" in English?


Yes.

But I don't understand why people use languages other than English.




Regards
Vishwas
SCJP 1.4
SCJA
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... I guess he just assumed Chris Allen was from the subcontinent. Honest mistake
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic