LWN.net Logo

That's the problem witrh GC

That's the problem witrh GC

Posted Aug 22, 2011 19:31 UTC (Mon) by kleptog (subscriber, #1183)
In reply to: That's the problem witrh GC by endecotp
Parent article: HP dropping webOS devices

Memory pools are also used in PostgreSQL. They have the fantastic property of being able to say 'this transaction is aborted, forget everything related to it in almost constant time'. They're useful when dealing with user code because you can arrange for the code the work in a particular context and when the code is done, you simple clear the context in one go.

It's not free though. It does mean that if you want data to survive for longer periods it means you need to copy the data to a new context. It means that for functions the context of associated memory becomes part of the API and you need to be careful that people respect the conventions, or you get dangling pointers easily. And valgrind gets confused. And external libraries don't get along well with it some times. And you don't get destructors (although I understand Samba has a memory pool architecture with destructors).

But you never get memory leaks, which is good for reliability. And that makes up for a lot.


(Log in to post comments)

That's the problem witrh GC

Posted Aug 23, 2011 10:59 UTC (Tue) by jwakely (subscriber, #60262) [Link]

Yeah, memory pools are great. In a previous life I grafted C++ destructors onto Apache memory pools, IIRC by overloading 'new' to register functions to be run when the pool gets torn down.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds