Results 1 to 4 of 4
  1. #1
    the5thace is offline Member
    Join Date
    Jul 2012
    Posts
    1
    Rep Power
    0

    Default Resource leak on eclipse. How to fix?

    Hello, I'm a total beginner and am following along these video lessons http://www.youtube.com/watch?v=ANuuS...hannel&list=UL and I'm getting a Resource leak error on line 4. What am I doing wrong?
    Java Code:
    import java.util.Scanner;
    class Cal{
    	public static void main(String [] args){
    		Scanner bucky = new Scanner(System.in);
    		double fnum, snum, answer;
    		System.out.println("enter first num: ");
    		fnum = bucky.nextDouble();
    		System.out.println("Enter your second number: ");
    		snum = bucky.nextDouble();
    		answer = fnum + snum; 
    		System.out.println(answer);
    	}
    	}
    I greatly appreciate any help!
    Last edited by JosAH; 07-11-2012 at 10:49 AM. Reason: added [code] ... [/code] tags

  2. #2
    Waflix is offline Member
    Join Date
    Jul 2012
    Location
    Zuid-Holland, The Netherlands
    Posts
    16
    Rep Power
    0

    Default Re: Resource leak on eclipse. How to fix?

    I'm not having any errors when trying to run this. So at least it's not the code that's wrong.
    As I'm not really good at explaining stuff, I've got both a link and a copied piece of text for you:
    "unintentional maintenence of references to non-memory resources" - What is a resource leak?

  3. #3
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,802
    Rep Power
    19

    Default Re: Resource leak on eclipse. How to fix?

    Please use [code] tags [/code] when posting code.
    Also please post the full error and any stack trace and highlight the line it occurs on.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    FussyCashew is offline Member
    Join Date
    Jun 2012
    Location
    Ohio
    Posts
    10
    Rep Power
    0

    Default Re: Resource leak on eclipse. How to fix?

    I'd assume it is because you are not closing the Scanner. Eclipse gives a warning when readers are never closed.
    If it is a warning, all you'd need to do is close the Scanner.

Similar Threads

  1. avoid memory leak
    By Sergey Livanov in forum Advanced Java
    Replies: 10
    Last Post: 12-20-2011, 04:10 PM
  2. Memory leak in swing
    By smeshram in forum AWT / Swing
    Replies: 7
    Last Post: 12-08-2011, 03:52 AM
  3. Memory Leak questions, code review
    By mensaFool in forum Advanced Java
    Replies: 9
    Last Post: 03-08-2010, 04:27 PM
  4. Socket Class Leak
    By mbmsit in forum Networking
    Replies: 3
    Last Post: 02-20-2010, 12:09 PM
  5. Help I have a memory leak...
    By cdman52 in forum Java Applets
    Replies: 10
    Last Post: 09-28-2009, 10:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •