-
Notifications
You must be signed in to change notification settings - Fork 273
Use shared_ptr in irept #685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Unfortunately, I get very similar results, so I don't think it solves #569. |
I'll take a look at this one, but it would have been very nice if the diff had been minimal rather than including a sleuth of other changes. |
I would be curious to learn whether there's any performance/memory usage difference. |
Using some simple irept tests I had built some time ago the only observable difference in memory consumption is the size of an irept, which now is the size of two pointers instead of just one:
|
On Thu, 2017-03-23 at 11:37 -0700, Michael Tautschnig wrote:
Using some simple irept tests I had built some time ago the only observable difference in memory consumption is the size of an irept, which now is the size of two pointers instead of just one:
I'm mildly concerned by this. Memory consumption is a serious issue for
some users.
|
Well, as far as I understand we are just moving those extra bytes out of the inner structure, which would always get allocated together with an |
To clarify my surprise: the gap is now just replaced by padding, so we do end up with some overhead. Proper measurements at large scale are due, though. |
irept
was doing manual reference-counting. Applying the single responsibility principle, we replace manual pointer/refcount manipulation withstd::shared_ptr
, so that the innerdt
class does not have the dual responsibilities of maintaining a reference count and storing the object data members. Usingshared_ptr
improves the maintainability of the code, as it is a well-known and well-documented abstraction.shared_ptr
also allows us to use the compiler-generated special member functions, so that there is less overall code to maintain.