You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "mapleFU (via GitHub)" <gi...@apache.org> on 2023/04/22 05:42:30 UTC

[GitHub] [arrow] mapleFU commented on issue #35270: Memory leak in SwissTable::grow_double()

mapleFU commented on issue #35270:
URL: https://github.com/apache/arrow/issues/35270#issuecomment-1518520250

   I think `pool_->Allocate` returns a buffer with `MemoryManager`:
   
   ```c++
     static std::unique_ptr<PoolBuffer> MakeUnique(MemoryPool* pool, int64_t alignment) {
       std::shared_ptr<MemoryManager> mm;
       if (pool == nullptr) {
         pool = default_memory_pool();
         mm = default_cpu_memory_manager();
       } else {
         mm = CPUDevice::memory_manager(pool);
       }
       return std::make_unique<PoolBuffer>(std::move(mm), pool, alignment);
     }
   ```
   
   When `PoolBuffer` destruct, it will release pool memory:
   
   ```c++
     ~PoolBuffer() override {
       // Avoid calling pool_->Free if the global pools are destroyed
       // (XXX this will not work with user-defined pools)
   
       // This can happen if a Future is destructing on one thread while or
       // after memory pools are destructed on the main thread (as there is
       // no guarantee of destructor order between thread/memory pools)
       uint8_t* ptr = mutable_data();
       if (ptr && !global_state.is_finalizing()) {
         pool_->Free(ptr, capacity_, alignment_);
       }
     }
   ```
   
   If I'm wrong, please point out that


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org