This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 95020 - Thread objects not garbage collected when profiling
Summary: Thread objects not garbage collected when profiling
Status: RESOLVED FIXED
Alias: None
Product: profiler
Classification: Unclassified
Component: Base (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: Tomas Hurka
URL:
Keywords:
: 96566 99331 101221 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-02-08 22:44 UTC by kolotyluk
Modified: 2007-04-16 21:20 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kolotyluk 2007-02-08 22:44:40 UTC
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 _ moser 2007-02-14 09:35:21 UTC
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 Tomas Hurka 2007-02-14 10:38:29 UTC
Fixed in trunk.
Comment 3 Tomas Hurka 2007-02-19 12:59:35 UTC
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 Tomas Hurka 2007-02-21 15:20:55 UTC
Fix merged to release551 branch
Comment 5 Tomas Hurka 2007-02-26 12:25:46 UTC
*** Issue 96566 has been marked as a duplicate of this issue. ***
Comment 6 Tomas Hurka 2007-03-30 08:32:19 UTC
*** Issue 99331 has been marked as a duplicate of this issue. ***
Comment 7 Jiri Sedlacek 2007-04-16 21:20:21 UTC
*** Issue 101221 has been marked as a duplicate of this issue. ***