Page 1 of 1

function to return available GPU memory?

Posted: Sat Apr 14, 2018 6:03 pm
by Brian Beuken
Aside from the obvious idea of keeping track of all memory you allocate, that won't really help if you don't know the size of the memory allocated to the GPU in preferences.


Is there a simple way to find out how much GPU memory has been allocated, and how much is still free?

Re: function to return available GPU memory?

Posted: Mon Apr 16, 2018 7:53 am
by hjimbens
As far as I know there is no direct call to query this, but

Code: Select all

popen ("sudo vcdbg reloc stats", "r")
returns a FILE pointer to a file containing something like

Code: Select all

total space allocated is 236M, with 234M relocatable, 2.3M legacy and 0 offline
143M free memory in 35 free block(s)
You can parse it to read the 236M and 143M.
Of course, this is not going to be fast, so you should use it judiciously.

Re: function to return available GPU memory?

Posted: Mon Apr 16, 2018 1:40 pm
by Brian Beuken
Thanks I only really need it at start up to set up the current amounts, I can calculate the remainders with reach allocation