cornercorner
FeaturesPluginsDocs & SupportCommunityPartners

Bug 95020 - Thread objects not garbage collected when profiling
: Thread objects not garbage collected when profiling
Status: RESOLVED FIXED
: profiler
Base
: 5.5
: All All
: P3 (vote)
: 5.5
Assigned To:
:
:
:
:
:
:
  Show dependency treegraph
 
Reported: 2007-02-08 22:44 by
Modified: 2007-04-16 21:20 (History)
Issue Type: DEFECT
:


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2007-02-08 22:44:40
Run the following program under the profiler and turn on memory profiling. You 
will see that the finalize methods never get called, and the profiling data 
shows the Main thread objects are never garbage collected. Run the program as 
normal (without the profiler) and you will see that the finalize methods do 
get called. This is very misleading when you are trying to find memory leaks 
using the profiler.

See also http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6520834

/*
 * Main.java
 *
 * Created on February 8, 2007, 10:31 AM
 */

package Threads;

/**
 *
 * @author ekolotyluk
 */
public class Main extends Thread
{ 
    public void run()
    {
        System.out.println(getName() + " - starting");
        try
        {
            sleep((int) (Math.random() * 100000));
        }
        catch (InterruptedException e)
        {

        }
        System.out.println(getName() + " -         stopping");
    }

    public void finalize()
    {
        System.out.println(getName() + " -                  finalizing");
    }

    public static void main(String [] arguments)
    {
        for (int i = 0; i < 100; i++)
        {
            Main main = new Main();
            main.start();
            try
            {
                Thread.sleep(2000);
                System.gc();
            }
            catch (InterruptedException e)
            {

            }
        }

        System.exit(0);
    }
}
------- Comment #1 From 2007-02-14 09:35:21 -------
Maybe worth to mention: as I have reported on the mailing list (see
http://article.gmane.org/gmane.comp.java.netbeans.modules.profiler.user/477),
only those threads are not garbage collected, which did create new objects
(what
obviously most of all meaningful threads will do). But this might be
interesting
for debugging the problem.

Frank-Michael
------- Comment #2 From 2007-02-14 10:38:29 -------
Fixed in trunk.
------- Comment #3 From 2007-02-19 12:59:35 -------
Patch for NetBeans Profiler 5.5 was made available.
Download patch available here 
http://profiler.netbeans.org/download/patches/patch_for_issue_95020.zip
and follow instructions in README.txt file
------- Comment #4 From 2007-02-21 15:20:55 -------
Fix merged to release551 branch
------- Comment #5 From 2007-02-26 12:25:46 -------
*** Issue 96566 has been marked as a duplicate of this issue. ***
------- Comment #6 From 2007-03-30 08:32:19 -------
*** Issue 99331 has been marked as a duplicate of this issue. ***
------- Comment #7 From 2007-04-16 21:20:21 -------
*** Issue 101221 has been marked as a duplicate of this issue. ***