This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes resource leakage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "resource leakage" Watch "resource leakage" New topic
Author

resource leakage

kotha vijaybabu
Ranch Hand

Joined: Jan 28, 2006
Posts: 77
wat is the resource leakage in java
Chris Allen
Ranch Hand

Joined: Feb 01, 2003
Posts: 127
Can you be a little more specific with your question? Are you referring to delayed garbage collection?
kotha vijaybabu
Ranch Hand

Joined: Jan 28, 2006
Posts: 77
no yaar its a interview question actually i dontknow in which perspect it was asked
ravi rasa
Greenhorn

Joined: Nov 20, 2003
Posts: 15
Hi,

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

Ravi.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

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.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

"Yaar"? Be you a pirate, matey? Be you interviewing fer a piratin' position?


[Jess in Action][AskingGoodQuestions]
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114
    
  16

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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 ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Originally posted by Ernest Friedman-Hill:
"Yaar"? Be you a pirate, matey? Be you interviewing fer a piratin' position?


yaar


There is no emoticon for what I am feeling!
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114
    
  16

So "yaar" means something like "pal" in English?
Vishwas Hegde
Ranch Hand

Joined: Oct 02, 2003
Posts: 212

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

Joined: Sep 16, 2005
Posts: 1780
... I guess he just assumed Chris Allen was from the subcontinent. Honest mistake
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: resource leakage