Brian Beuken
Posts: 79
Joined: Fri Jan 29, 2016 12:51 pm

function to return available GPU memory?

Sat Apr 14, 2018 6:03 pm

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?
Very old computer game programmer, now teaching very young computer game programmers, some very bad habits.
Wrote some book about coding Pi's and SBC's, it's out now...go get it!
http://www.scratchpadgames.net/

hjimbens
Posts: 43
Joined: Fri May 24, 2013 9:05 am

Re: function to return available GPU memory?

Mon Apr 16, 2018 7:53 am

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.

Brian Beuken
Posts: 79
Joined: Fri Jan 29, 2016 12:51 pm

Re: function to return available GPU memory?

Mon Apr 16, 2018 1:40 pm

Thanks I only really need it at start up to set up the current amounts, I can calculate the remainders with reach allocation
Very old computer game programmer, now teaching very young computer game programmers, some very bad habits.
Wrote some book about coding Pi's and SBC's, it's out now...go get it!
http://www.scratchpadgames.net/

Return to “OpenGLES”

Who is online

Users browsing this forum: No registered users and 0 guests