Updated sql mem alloc, now uses shared pointers for memory allocation.