Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Celanup memory when initializing pthread mutex #61

Closed
mkushnir opened this Issue Jan 17, 2016 · 4 comments

Comments

Projects
None yet
3 participants
Contributor

mkushnir commented Jan 17, 2016

Found missing destroy calls, please find in attachment
out.txt

Contributor

kmcdonell commented Jan 20, 2016

Thanks for the patch it is good to see the code being reviewed by fresh eyes.

But in these case I don't believe that the destroy is required ... the attr is allocated on the stack and the storage is reclaimed when the block is exited (just after the places where you're suggesting the destroy should be added).

I'll close this issue in a couple of days unless there is new information to suggest my analysis is wrong.

Cheers, Ken

Contributor

fche commented Jan 20, 2016

For reference, glibc's pthread_mutexattr_destroy() is a no-op. I don't know of an implementation that hangs dynamically allocated data off of a mutexattr (so as to require a _destroy to avoid leaking it), but the POSIX text doesn't seem to forbid it.

Contributor

kmcdonell commented Jan 21, 2016

OK, thanks Frank ... I'll commit mkushnir's patch as it would seem to be (at worst) harmless.

@kmcdonell kmcdonell closed this Jan 21, 2016

Contributor

mkushnir commented Jan 21, 2016

As a followup, I'm on FreeBSD, and caught it with the help of valrind. Looks like FreeBSD's implementation allocates some extra memory. I thought it's worth of fixing, since I write a long-living app (months uptime), archive contexts would be created as new archives appear, so my memory would slowly grow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment