[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Condor-devel] shared_ptr in classads
- Date: Wed, 11 Jul 2012 18:20:19 -0500
- From: Dan Bradley <dan@xxxxxxxxxxxx>
- Subject: [Condor-devel] shared_ptr in classads
Hi all,
In order to fix the following memory leak in classads
https://condor-wiki.cs.wisc.edu/index.cgi/tktview?tn=3082
I would have liked to use shared_ptr for pointers to ExprList and
ClassAd objects in the classad Value object. This would allow us to
have ClassAd functions that return dynamically generated lists and ads.
Both ExprList and ClassAd derive from ExprTree and are frequently
pointed to via a pointer to the base class, so one approach would be to
use shared_ptr for all places where ExprTree objects are owned in the
ClassAd library. I have several concerns with this:
1. extra heap allocation for the reference counter for every ExprTree
(i.e. every little piece of every classad expression)
2. impact on public interfaces
I am concerned that if we change all the public interfaces, we will end
up having to change ClassAd* to shared_ptr<ClassAd> throughout much of
condor. I think this is reasonably straightforward and probably the
"right" thing to do, but touching that much code isn't ideal. I would
want to know that everyone is wildly enthusiastic first.
One alternative to the big conversion to shared_ptr throughout condor is
to just add another type within the Value object: an "owned" list. When
you want to put a list into a Value, you would have to choose between
giving the Value object ownership or not. It's not as nice of an
interface, but we don't often write new classad functions that create
dynamic lists.
After playing with the shared_ptr approach, I have concluded that unless
I hear that people are gung-ho about converting to shared_ptr throughout
Condor, the minimal approach is better for now.
Thoughts?
--Dan