Why don't explicit free cpu resource in CachingHostAllocator

Hi, boss.
For CPU block resources are not free.

Through there is a API empty_cache can release resource, but this API is not using now.

So why don’t explicit free those resources, and how to ensure resources are not leaked.

A caching allocator tries to avoid allocating and freeing memory for each use for performance reasons. Resources can be freed by explicitly clearing the cache or at the teardown. Also the CUDACachingAllocator will free the cache in case it’s running OOM before retrying the allocation again.

Yep, this is ok. There are also two questions about this.

  1. CachingHostAllocator don’t free cache when OOM, this will be directly failed;
    2)According empty_cache function, just free cudaEvent and pin memory from cudaHostAlloc directly without any device sync, this is OK?

Why would you need a device sync to free page-locked memory on the host?

In async mode, page-locked memory maybe freed before kernel using this memory.
After read the codes, i found this is safe, because CachingHostAllocator_recordEvent and cudaFreeHost keep page-locked memory alive until kernel finished.
Thanks a lot.