How the data member `data_` of TensorBuffer is destroyed?
The `data_ `member is indeed a `void`* pointer, but it doesn't directly own the memory it points to. The actual memory management depends on the T`ensorBuffer'`s underlying data type and allocation strategy. The RefCounted::Unref function you mentioned does indeed call delete this when the reference count reaches zero. However, this delete only deallocates the TensorBuffer object itself, not the memory pointed to by data_.
The responsibility of de-allocating the actual data belongs to the specific allocation mechanism used for that data type. TensorFlow internally handles this through its memory management system.

Please let us know if it clarifies your query?
Thank you! @sushreebarsa Thanks for your reply. I got some idea. Here is my description:

Take this [constructor](https://github.com/tensorflow/tensorflow/blob/23bc3342fcc7d4bf1da6f2f11da61da55d290d34/tensorflow/core/framework/tensor.cc#L967) as an example,

https://github.com/tensorflow/tensorflow/blob/23bc3342fcc7d4bf1da6f2f11da61da55d290d34/tensorflow/core/framework/tensor.cc#L967-L978

`buf_ = new Buffer<T>(a, shape.num_elements())` sets the `buf_` member of `Tensor`. Here `Buffer` is a subclass of `TensorBuffer`, its destructor:

https://github.com/tensorflow/tensorflow/blob/23bc3342fcc7d4bf1da6f2f11da61da55d290d34/tensorflow/core/framework/tensor.cc#L577-L585

When `Tensor` object is destroyed, it will call `buf_ `'s destructor.

The `TypedAllocator::Deallocate` then deallocate the memory which ultimately calls `DeallocateRaw` method of the allocator that is used in constructor.

Is it looks this what I describe above?

From the `TensorBuffer ` definition, I notice there is a member `data_`
https://github.com/tensorflow/tensorflow/blob/b7ee894eba3b725eafdd70b088029e907f7943c7/tensorflow/core/framework/tensor.h#L108

I am curious about how this void pointer will be destroyed?

I find `RefCounted::Unref` has the logic of `delete`, especially the following line:

https://github.com/tensorflow/tensorflow/blob/b7ee894eba3b725eafdd70b088029e907f7943c7/third_party/xla/third_party/tsl/tsl/platform/refcount.h#L336

but it seems the above line did not delete what the void pointer `data_` is pointing to.