Reputation: 19
I have a af::array
variable which is 3000000*3:
int main()
{
// inputArray is the pointer which fills tempArray
af::array tempArray = af::array(af::dim4(3000000,3),inputArray);
tempArray(tempArray < 0) = 0;
}
the problem is that, I want to delete this array so that my memory gets released, it fills my dedicated GPU memory. How should I do it?
Before using this variable enter image description here
after using this variable: enter image description here
Upvotes: 1
Views: 313
Reputation: 993
It's important to understand that ArrayFire uses a garbage collector. This means that even when you release the memory, the memory on the GPU won't be released but marked as reusable and later used when needed by you (ArrayFire) library.
Allocating memory is expensive that's why software designers strive to use custom allocation systems that reuse and allocate memory in bulk.
To manually return memory to garbage collector use either af::freeV2()
or af::deviceGC()
.
Upvotes: 1