diff options
-rw-r--r-- | tensorflow/core/platform/mem.h | 9 | ||||
-rw-r--r-- | tensorflow/core/platform/posix/port.cc | 4 |
2 files changed, 13 insertions, 0 deletions
diff --git a/tensorflow/core/platform/mem.h b/tensorflow/core/platform/mem.h index 3383d031d8..8e7a18c55d 100644 --- a/tensorflow/core/platform/mem.h +++ b/tensorflow/core/platform/mem.h @@ -37,6 +37,15 @@ namespace port { void* aligned_malloc(size_t size, int minimum_alignment); void aligned_free(void* aligned_memory); +// Tries to release num_bytes of free memory back to the operating +// system for reuse. Use this routine with caution -- to get this +// memory back may require faulting pages back in by the OS, and +// that may be slow. +// +// Currently, if a malloc implementation does not support this +// routine, this routine is a no-op. +void MallocExtension_ReleaseToSystem(std::size_t num_bytes); + // Returns the actual number N of bytes reserved by the malloc for the // pointer p. This number may be equal to or greater than the number // of bytes requested when p was allocated. diff --git a/tensorflow/core/platform/posix/port.cc b/tensorflow/core/platform/posix/port.cc index 1877dfeddc..c8c57753b7 100644 --- a/tensorflow/core/platform/posix/port.cc +++ b/tensorflow/core/platform/posix/port.cc @@ -77,6 +77,10 @@ void* aligned_malloc(size_t size, int minimum_alignment) { void aligned_free(void* aligned_memory) { free(aligned_memory); } +void MallocExtension_ReleaseToSystem(std::size_t num_bytes) { + // No-op. +} + std::size_t MallocExtension_GetAllocatedSize(const void* p) { return 0; } void AdjustFilenameForLogging(string* filename) { |