@@ -132,10 +132,15 @@ DetectedFormat detect_format(filesystem::Path path)
132132}
133133
134134
135- Framework* CuImage::framework_ = cucim::acquire_framework(" cucim" );
136- std::unique_ptr<config::Config> CuImage::config_ = std::make_unique<config::Config>();
137- std::unique_ptr<cache::ImageCacheManager> CuImage::cache_manager_ = std::make_unique<cache::ImageCacheManager>();
138- std::unique_ptr<plugin::ImageFormat> CuImage::image_format_plugins_ = std::make_unique<plugin::ImageFormat>();
135+ // Framework* CuImage::framework_ = cucim::acquire_framework("cucim");
136+ // std::unique_ptr<config::Config> CuImage::config_ = std::make_unique<config::Config>();
137+ // std::unique_ptr<cache::ImageCacheManager> CuImage::cache_manager_ = std::make_unique<cache::ImageCacheManager>();
138+ // std::unique_ptr<plugin::ImageFormat> CuImage::image_format_plugins_ = std::make_unique<plugin::ImageFormat>();
139+
140+ Framework* CuImage::framework_ = nullptr ;
141+ std::unique_ptr<config::Config> CuImage::config_ = nullptr ;
142+ std::unique_ptr<cache::ImageCacheManager> CuImage::cache_manager_ = nullptr ;
143+ std::unique_ptr<plugin::ImageFormat> CuImage::image_format_plugins_ = nullptr ;
139144
140145
141146CuImage::CuImage (const filesystem::Path& path)
@@ -228,73 +233,73 @@ CuImage::CuImage() : std::enable_shared_from_this<CuImage>()
228233
229234CuImage::~CuImage ()
230235{
231- // printf("[cuCIM] CuImage::~CuImage()\n");
232- close ();
233- image_format_ = nullptr ; // memory release is handled by the framework
234- if (image_metadata_)
235- {
236- // Memory for json_data needs to be manually released if image_metadata_->json_data is not ""
237- if (image_metadata_->json_data && *image_metadata_->json_data != ' \0 ' )
238- {
239- cucim_free (image_metadata_->json_data );
240- image_metadata_->json_data = nullptr ;
241- }
242- // Delete object (cucim::io::format::ImageMetadata) that embeds image_metadata_
243- if (image_metadata_->handle )
244- {
245- // Keep original handle pointer before clearing it and delete the class object.
246- void * handle_ptr = image_metadata_->handle ;
247- image_metadata_->handle = nullptr ;
248- delete static_cast <cucim::io::format::ImageMetadata*>(handle_ptr);
249- }
250- image_metadata_ = nullptr ;
251- }
252- if (image_data_)
253- {
254- if (image_data_->container .data )
255- {
256- DLContext& ctx = image_data_->container .ctx ;
257- auto device_type = static_cast <io::DeviceType>(ctx.device_type );
258- switch (device_type)
259- {
260- case io::DeviceType::kCPU :
261- cucim_free (image_data_->container .data );
262- image_data_->container .data = nullptr ;
263- break ;
264- case io::DeviceType::kCUDA :
265- cudaError_t cuda_status;
266- CUDA_TRY (cudaFree (image_data_->container .data ));
267- image_data_->container .data = nullptr ;
268- if (cuda_status)
269- {
270- fmt::print (stderr, " [Error] Cannot free memory!" );
271- }
272- break ;
273- case io::DeviceType::kPinned :
274- case io::DeviceType::kCPUShared :
275- case io::DeviceType::kCUDAShared :
276- fmt::print (stderr, " Device type {} is not supported!" , device_type);
277- break ;
278- }
279- }
280- if (image_data_->container .shape )
281- {
282- cucim_free (image_data_->container .shape );
283- image_data_->container .shape = nullptr ;
284- }
285- if (image_data_->container .strides )
286- {
287- cucim_free (image_data_->container .strides );
288- image_data_->container .strides = nullptr ;
289- }
290- if (image_data_->shm_name )
291- {
292- cucim_free (image_data_->shm_name );
293- image_data_->shm_name = nullptr ;
294- }
295- cucim_free (image_data_);
296- image_data_ = nullptr ;
297- }
236+ // // printf("[cuCIM] CuImage::~CuImage()\n");
237+ // close();
238+ // image_format_ = nullptr; // memory release is handled by the framework
239+ // if (image_metadata_)
240+ // {
241+ // // Memory for json_data needs to be manually released if image_metadata_->json_data is not ""
242+ // if (image_metadata_->json_data && *image_metadata_->json_data != '\0')
243+ // {
244+ // cucim_free(image_metadata_->json_data);
245+ // image_metadata_->json_data = nullptr;
246+ // }
247+ // // Delete object (cucim::io::format::ImageMetadata) that embeds image_metadata_
248+ // if (image_metadata_->handle)
249+ // {
250+ // // Keep original handle pointer before clearing it and delete the class object.
251+ // void* handle_ptr = image_metadata_->handle;
252+ // image_metadata_->handle = nullptr;
253+ // delete static_cast<cucim::io::format::ImageMetadata*>(handle_ptr);
254+ // }
255+ // image_metadata_ = nullptr;
256+ // }
257+ // if (image_data_)
258+ // {
259+ // if (image_data_->container.data)
260+ // {
261+ // DLContext& ctx = image_data_->container.ctx;
262+ // auto device_type = static_cast<io::DeviceType>(ctx.device_type);
263+ // switch (device_type)
264+ // {
265+ // case io::DeviceType::kCPU:
266+ // cucim_free(image_data_->container.data);
267+ // image_data_->container.data = nullptr;
268+ // break;
269+ // case io::DeviceType::kCUDA:
270+ // cudaError_t cuda_status;
271+ // CUDA_TRY(cudaFree(image_data_->container.data));
272+ // image_data_->container.data = nullptr;
273+ // if (cuda_status)
274+ // {
275+ // fmt::print(stderr, "[Error] Cannot free memory!");
276+ // }
277+ // break;
278+ // case io::DeviceType::kPinned:
279+ // case io::DeviceType::kCPUShared:
280+ // case io::DeviceType::kCUDAShared:
281+ // fmt::print(stderr, "Device type {} is not supported!", device_type);
282+ // break;
283+ // }
284+ // }
285+ // if (image_data_->container.shape)
286+ // {
287+ // cucim_free(image_data_->container.shape);
288+ // image_data_->container.shape = nullptr;
289+ // }
290+ // if (image_data_->container.strides)
291+ // {
292+ // cucim_free(image_data_->container.strides);
293+ // image_data_->container.strides = nullptr;
294+ // }
295+ // if (image_data_->shm_name)
296+ // {
297+ // cucim_free(image_data_->shm_name);
298+ // image_data_->shm_name = nullptr;
299+ // }
300+ // cucim_free(image_data_);
301+ // image_data_ = nullptr;
302+ // }
298303}
299304
300305Framework* CuImage::get_framework ()
0 commit comments