Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Rename release_all -> empty_cache and provide documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
vlado committed May 7, 2019
1 parent f63d1d1 commit b16a96c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion python/mxnet/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,20 @@ def default_ctx(cls, val):
cls._default_ctx.value = val
#pylint: enable=no-self-argument

def release_all(self):
def empty_cache(self):
"""Empties the memory cache for the current contexts device.
MXNet utilizes a memory pool to avoid excessive allocations.
Calling empty_cache will empty the memory pool of the contexts
device. This will only free the memory of unreferenced data.
Examples
-------
>>> ctx = mx.gpu(0)
>>> arr = mx.nd.ones((200,200), ctx=ctx)
>>> del arr
>>> ctx.empty_cache() # forces release of memory allocated for arr
"""
dev_type = ctypes.c_int(self.device_typeid)
dev_id = ctypes.c_int(self.device_id)
check_call(_LIB.MXStorageReleaseAll(dev_type, dev_id))
Expand Down

0 comments on commit b16a96c

Please sign in to comment.