Results 1 to 8 of 8
Like Tree1Likes
  • 1 Post By doWhile

Thread: Memory leak in swing

  1. #1
    smeshram is offline Member
    Join Date
    Dec 2011
    Posts
    3
    Rep Power
    0

    Default Memory leak in swing

    I am facing memory leak problem in my swing based application. After following a series of steps (after opening and closing same frame 10 - 15 times) application is throwing OOM exception on GUI. When I analyzed heap dump with EMA (eclipse memory analyzer) it is showing that the common point of accumulation is KeyboardManager which is holding the reference in the collection to the object on the frame which is not visible on GUI. Please help me who we can dereference all object from keyboard manager.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,039
    Rep Power
    10

    Default Re: Memory leak in swing

    Chances are this is a memory leak in your code, not in Swing. Can you reproduce the problem with an SSCCE?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    smeshram is offline Member
    Join Date
    Dec 2011
    Posts
    3
    Rep Power
    0

    Default Re: Memory leak in swing

    Do u have any idea why keyboard manager is having reference to the closed frame?? I guess it is internally handle by swing when any component become invisible.

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,039
    Rep Power
    10

    Default Re: Memory leak in swing

    Without seeing an SSCCE, I have no idea why any of the code is doing anything.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Memory leak in swing

    This is a known issue associated with Swing's use of strong references when you want to use weak ones. There are work arounds to be found if you Google the terms -- java swing references memory strong weak --

  6. #6
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: Memory leak in swing

    Quote Originally Posted by Fubarable View Post
    This is a known issue associated with Swing's use of strong references when you want to use weak ones. There are work arounds to be found if you Google the terms -- java swing references memory strong weak --
    Ironically, the first hit when I just did the search was this thread ;)
    Fubarable likes this.

  7. #7
    smeshram is offline Member
    Join Date
    Dec 2011
    Posts
    3
    Rep Power
    0

    Default Re: Memory leak in swing

    Yes, I think it is a swing bug. Detailed explanation is given below

    bestsss here: Swing and the Leaks (part 1 of ...)

  8. #8
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,039
    Rep Power
    10

    Default Re: Memory leak in swing

    This is the first time I've seen somebody claim to have found a bug when it was actually a bug. Well done. Sorry for my skepticism.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Replies: 1
    Last Post: 07-18-2011, 05:24 PM
  2. Memory Leak questions, code review
    By mensaFool in forum Advanced Java
    Replies: 9
    Last Post: 03-08-2010, 05:27 PM
  3. Help I have a memory leak...
    By cdman52 in forum Java Applets
    Replies: 10
    Last Post: 09-28-2009, 11:37 PM
  4. java.util.logging.StreamHandler memory leak?
    By toadaly in forum Advanced Java
    Replies: 1
    Last Post: 02-23-2009, 03:46 PM
  5. Memory Leak using a Swing Application Project
    By iimasd in forum AWT / Swing
    Replies: 0
    Last Post: 11-27-2007, 11:20 AM

Posting Permissions

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