Skip to content

Commit

Permalink
Don't count mapped allocations (#42)
Browse files Browse the repository at this point in the history
Mapped allocations don't use device memory, so we will not count them
with the device memory counter.
  • Loading branch information
lcw authored and dmed256 committed Nov 24, 2016
1 parent 246fff7 commit 381e886
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,8 @@ namespace occa {
void memory::free() {
checkIfInitialized();

mHandle->dHandle->bytesAllocated -= (mHandle->size);
if(!mHandle->isMapped())
mHandle->dHandle->bytesAllocated -= (mHandle->size);

if(mHandle->uvaPtr) {
uvaMap.erase(mHandle->uvaPtr);
Expand Down Expand Up @@ -1617,7 +1618,8 @@ namespace occa {
void memory::detach() {
checkIfInitialized();

mHandle->dHandle->bytesAllocated -= (mHandle->size);
if(!mHandle->isMapped())
mHandle->dHandle->bytesAllocated -= (mHandle->size);

if(mHandle->uvaPtr) {
uvaMap.erase(mHandle->uvaPtr);
Expand Down Expand Up @@ -2260,8 +2262,6 @@ namespace occa {
mem.mHandle = dHandle->mappedAlloc(bytes, src);
mem.mHandle->dHandle = dHandle;

dHandle->bytesAllocated += bytes;

return mem;
}

Expand Down

0 comments on commit 381e886

Please sign in to comment.