classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Memory leak in java.lang.Thread ?


From: Archie Cobbs
Subject: Memory leak in java.lang.Thread ?
Date: Tue, 7 Dec 2004 17:43:03 -0600 (CST)

Hi,

I'm trying to verify a memory leak in Classpath but since my VM has
some modifications I thought I'd quickly ask the list to try this test.

What happens when you run this program:

    public class ThreadLeak {
        public static void main(String[] args) {
            while (true)
                new Thread();
        }
    }

I get an OutOfMemoryError. This is because new threads are added
to their ThreadGroups in the Thread() constructor rather than when
the thread is actually started. Therefore, even if they are never
started they remain referenced an unable to be garbage collected.

If it's not just me then I'll file a bug and propose a patch.

Thanks,
-Archie

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com


*
Confidentiality Notice: This e-mail message, including any attachments, is for 
the sole use of the intended recipient(s) and may contain confidential and 
privileged information. Any unauthorized review, use, disclosure or 
distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply e-mail and destroy all copies of 
the original message.
*





reply via email to

[Prev in Thread] Current Thread [Next in Thread]