Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mach_port_deallocate(kernel_thread) failed: (os/kern) invalid



If  I may butt in here, your program is not doing what you think it is.  Like I 
told you when we were talking about this last month, threads need to be joined 
or detached.  There are three ways to release these resources being taken up by 
a thread, and all are mutually exclusive:

Create it detached
Detach it
Join in.

Pick one.  It's important to do exactly one of these things with your thread, or 
you will leak memory.

It sounds likely to me that you aren't pthread_join()'ing a valid thread handle? 
That would explain both the kernel warnings and the fact a pthread_detach() is 
needed despite your pthread_join() call to release the extra memory.  At any 
rate, if your testing indicates otherwise, then you have a bug in your program 
that is causing it to not join where, when or what you think it is.

----- Original Message ----- 
From: "Marc Van Olmen" <email@hidden>
To: "Matt Watson" <email@hidden>
Cc: <email@hidden>
Sent: Sunday, October 31, 2004 8:03 PM
Subject: Re: mach_port_deallocate(kernel_thread) failed: (os/kern) invalid



On Oct 31, 2004, at 10:43 PM, Matt Watson wrote:

Matt,


My tests do NOT justify what you are writing here. If I remove the
pthread_detach after the pthread_join. I notice that my virtual memory
(checking with Activity monitor) is growing.... because doing this
pthread_join 2000 times in this manner my program stopped working
because no more memory available and virtual memory of my app growed to
4GB. When I added the follwing:

if (mThread) {
pthread_detach(mThread);
}

I need the join so the PTHREAD_CREATE_DETACHED wasn't an option.

I had no more crashes, no more virtual memory leaks and no errors
anymore in the console, after testing for a long time.


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden

References: 
 >Re: mach_port_deallocate(kernel_thread) failed: (os/kern) invalid (From: Marc Van Olmen <email@hidden>)
 >Re: mach_port_deallocate(kernel_thread) failed: (os/kern) invalid (From: Matt Watson <email@hidden>)
 >Re: mach_port_deallocate(kernel_thread) failed: (os/kern) invalid (From: Marc Van Olmen <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.