|
Re: Shared pointers? Unique pointers?
Shared pointers assist in memory management. They are implemented using an atomic reference count with the underlying resource (the Joystick object in your case) being shared with each copy of the shared pointer.
When a copy is created, the reference count is increased.
When a copy is destructed, the reference count is decreased. If the reference count reaches zero, the resource is also deleted.
It is better practice to pass your shared pointers by value instead of by reference. This makes it so that each scope owns a copy of your resource. I don't think this will fix your problem, though.
What do you mean by shared_ptr issue? Are you using multiple threads? Where is the initialization/declaration of your driveJoystick variable? It will be difficult to find the problem without seeing more of your code.
|