diff --git a/gtsam/base/GenericValue.h b/gtsam/base/GenericValue.h index 52899fe45..aee6c0e62 100644 --- a/gtsam/base/GenericValue.h +++ b/gtsam/base/GenericValue.h @@ -89,12 +89,9 @@ public: /** * Create a duplicate object returned as a pointer to the generic Value interface. - * For the sake of performance, this function use singleton pool allocator instead of the normal heap allocator. - * The result must be deleted with Value::deallocate_, not with the 'delete' operator. */ virtual Value* clone_() const { - void *place = boost::singleton_pool::malloc(); - GenericValue* ptr = new (place) GenericValue(*this); // calls copy constructor to fill in + GenericValue* ptr = new GenericValue(*this); // calls copy constructor to fill in return ptr; } @@ -102,8 +99,7 @@ public: * Destroy and deallocate this object, only if it was originally allocated using clone_(). */ virtual void deallocate_() const { - this->~GenericValue(); // Virtual destructor cleans up the derived object - boost::singleton_pool::free((void*) this); // Release memory from pool + delete this; } /** @@ -118,10 +114,7 @@ public: // Call retract on the derived class using the retract trait function const T retractResult = traits::Retract(GenericValue::value(), delta); - // Create a Value pointer copy of the result - void* resultAsValuePlace = - boost::singleton_pool::malloc(); - Value* resultAsValue = new (resultAsValuePlace) GenericValue(retractResult); + Value* resultAsValue = new GenericValue(retractResult); // Return the pointer to the Value base class return resultAsValue; @@ -172,12 +165,6 @@ public: return *this; } - private: - - /// Fake Tag struct for singleton pool allocator. In fact, it is never used! - struct PoolTag { - }; - private: /** Serialization function */