• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
CFFileDescriptor fd leak?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CFFileDescriptor fd leak?


  • Subject: CFFileDescriptor fd leak?
  • From: "A.M." <email@hidden>
  • Date: Thu, 20 Aug 2009 13:58:51 -0400

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

I am using CFFileDescriptor and it noticed that it seems to leak its kqueue file descriptor. Here is sample code demonstrating the problem:

//gcc test.c -framework CoreFoundation -g
#include <CoreFoundation/CoreFoundation.h>
#include <unistd.h>
#include <sys/event.h>

static void junkCallback(CFFileDescriptorRef fdref, CFOptionFlags callBackTypes, void *info) {}

// one argument, an integer pid to watch, required
int main(int argc, char *argv[]) {
int i;
for(i=0;i<3;i++)
{
CFFileDescriptorRef fdref = CFFileDescriptorCreate(kCFAllocatorDefault, 0, false, junkCallback, NULL);
CFFileDescriptorInvalidate(fdref);
CFRelease(fdref);
//CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1.0, false); // doesn't help to spin the runloop
}
sleep(100000);
return 0;
}




While the executable is sleeping, I run "lsof -p <pid>" and see the lines for open kqueue descriptors:

a.out 725 agentm 3u KQUEUE count=0, state=0
a.out 725 agentm 4u KQUEUE count=0, state=0
a.out 725 agentm 5u KQUEUE count=0, state=0


If I debug the executable, I can plainly see that the kqueue descriptors are opened in CFFileDescriptorCreate() but never closed.

Also, the sample code on the documentation page (http://developer.apple.com/documentation/CoreFoundation/Reference/CFFileDescriptorRef/Reference/reference.html ) also seems to leak two fds.

What am I missing?

Cheers,
M
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (Darwin)

iEYEARECAAYFAkqNjt8ACgkQqVAj6JpR7t5BwgCgm2K912i93tviOzkFbhNo8cyJ
Cn8AoJ8UOliN1+rsERGhGbbkFPD6uuM7
=xSEK
-----END PGP SIGNATURE-----
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: CFFileDescriptor fd leak?
      • From: Dave Keck <email@hidden>
    • Re: CFFileDescriptor fd leak?
      • From: "A.M." <email@hidden>
  • Prev by Date: Re: which pages of the file are in the cache
  • Next by Date: Re: List of accounts
  • Previous by thread: Runtime-linking of frameworks with variable paths, & replacing local symbols
  • Next by thread: Re: CFFileDescriptor fd leak?
  • Index(es):
    • Date
    • Thread