Re: getpwuid memory leak?!?
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com On 03.08.2005, at 23:40, Marc Majka wrote: -- Marc Majka On 3 Aug, 2005, at 10:16, Martin Bestmann wrote: Hi, getpwuid Here is a stack crawl returned by "ObjectAlloc" getpwuid getpw getpw_internal copy_user strdup malloc malloc_zone_malloc getpwuid getpw getpw_internal copy_user calloc I'm running on Mac OS X 10.4.2 Thanks, Martin _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/majka%40apple.com This email sent to majka@apple.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... The Mac OS X implementations of a number of routines found in libSystem, including getpwnam and getpwuid, have been modified to be thread-safe. Rather than returning a pointer to a static data structure, these routines allocate a structure for the returned value that is stored in thread-specific memory. The memory is recycled (by each thread) every time you make a call to one of these routines. That allows you to use these APIs safely in multi- threaded applications. The specific routines in the Libinfo project (see Libinfo/ lookup.subproj/lu_*.c) that maintain thread-specific memory for results are: - alias_getbyname alias_getent alias_setent alias_endent - bootp_getbyether bootp_getbyip - bootparams_getbyname bootparams_getent bootparams_setent bootparams_endent - getfsbyname getfsspec getfsfile getfsent setfsent endfsent - initgroups getgrnam getgrgid getgrent setgrent endgrent - gethostbyaddr gethostbyname gethostbyname2 gethostent sethostent endhostent - getipnodebyname getipnodebyaddr - innetgr getnetgrent setnetgrent endnetgrent - getnetbyaddr getnetbyname getnetent setnetent endnetent - prdb_getbyname prdb_get prdb_set prdb_end - getprotobyname getprotobynumber getprotoent setprotoent endprotoent - getrpcbyname getrpcbynumber getrpcent setrpcent endrpcent - getservbyport getservbyname getservent setservent endservent - getpwnam getpwuid getpwent setpwent endpwent Does this also mean when the thread terminates that the memory gets recycled. I could verify that the memory in the same thread gets recycled if I call getpwuid but I still have the memory allocated after my thread terminates. while running my App using "ObjectAlloc" I get memory allocation that are not deallocated / static allocated when calling Looking at the man pages I can not find any reference to the fact that I'm responsible for releasing the memory allocated in getpwuid. Is this a bug in the documentation or is this a bug in the OS that with each call to getpwuid memory gets allocated. This email sent to site_archiver@lists.apple.com
participants (1)
-
Martin Bestmann