Free iodevice memory when observer exit

This commit is contained in:
JiahuaChen
2023-05-25 17:11:17 +00:00
committed by ob-robot
parent e1e0ebaeb6
commit a66f2f136f
2 changed files with 18 additions and 13 deletions

View File

@ -62,18 +62,23 @@ int ObDeviceManager::init_devices_env()
void ObDeviceManager::destroy() void ObDeviceManager::destroy()
{ {
int ret_dev = OB_SUCCESS; int ret_dev = OB_SUCCESS;
int ret_handle = OB_SUCCESS; int ret_handle = OB_SUCCESS;
/*destroy fun wil release all the node*/ /*destroy fun wil release all the node*/
if (is_init_) { if (is_init_) {
ret_dev = device_map_.destroy(); ret_dev = device_map_.destroy();
ret_handle = handle_map_.destroy(); ret_handle = handle_map_.destroy();
allocator_.~ObFIFOAllocator();
if (OB_SUCCESS != ret_dev || OB_SUCCESS != ret_handle) { if (OB_SUCCESS != ret_dev || OB_SUCCESS != ret_handle) {
OB_LOG_RET(WARN, ret_dev, "fail to destroy device map", K(ret_dev), K(ret_handle)); OB_LOG_RET(WARN, ret_dev, "fail to destroy device map", K(ret_dev), K(ret_handle));
} }
//free the arena for (int i = 0; i < MAX_DEVICE_INSTANCE; i++ ) {
ObIODevice* del_device = device_ins_[i].device_;
if (OB_NOT_NULL(del_device)) {
del_device->destroy();
allocator_.free(del_device);
}
device_ins_[i].device_ = NULL;
}
allocator_.reset(); allocator_.reset();
fin_oss_env(); fin_oss_env();
is_init_ = false; is_init_ = false;

View File

@ -41,7 +41,7 @@ public:
private: private:
ObDeviceManager(); ObDeviceManager();
~ObDeviceManager() {} ~ObDeviceManager() { destroy(); }
struct ObDeviceInsInfo { struct ObDeviceInsInfo {
ObIODevice* device_; ObIODevice* device_;