Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: free memory of bufferedimage

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default free memory of bufferedimage

    hi all,

    i have the following code.

    BufferedImage img=new BufferedImage(29342,450,BufferedImage.TYPE_INT_RGB );

    Graphics2D g2d=img.createGraphics();
    g2d.drawImage(r.getAsBufferedImage(), 0, 0, null);
    g2d.finalize();
    g2d.dispose();

    img.flush();
    img=null;

    but i cannot free img object all uts memory since i know there is the reference to it, but for this problem how to solve it? thanks.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: free memory of bufferedimage

    You should not directly call finalize...this is for the garbage collector. The g2d.dispose() call should release all resources associated with the Graphics object you created. The garbage collector works on its own time, and it will free up the memory to unreferenced/out of scope objects when it sees fit - which may or may not be immediately

  3. #3
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: free memory of bufferedimage

    How much memory does this image take up?
    Whats the reason for loading an image in of this size anyways?

    // Json

Similar Threads

  1. SCJP free Training
    By kumarfair30 in forum The Cafe
    Replies: 0
    Last Post: November 2nd, 2009, 08:30 AM
  2. Java memory management
    By trueacumen in forum Java Theory & Questions
    Replies: 5
    Last Post: August 12th, 2009, 02:40 AM
  3. Replies: 2
    Last Post: June 29th, 2009, 03:06 PM
  4. Replies: 10
    Last Post: June 22nd, 2009, 07:45 AM
  5. Free java hosting service providers
    By servlet in forum Java Servlet
    Replies: 1
    Last Post: May 14th, 2009, 07:28 AM