Paul Draper
Paul Draper

Reputation: 83353

How much WebGL memory is available? What happens when I run out?

GPU memory is limited -- typically more limited than JS heap sizes, etc. Thing like lots of high resolution images can fill up the memory, and it is a shared resource, so other applications could be using a lot of it up.

In OpenGL, I can query for available memory.

Is there any way in WebGL do the same? How can I tell if I run out? What will happen if I do?

I'm not sure how to manage the experience for WebGL. I can fall back to SVGs or Canvas if necessary, but I don't know when that is necessary.

Upvotes: 7

Views: 7827

Answers (2)

SammieFox
SammieFox

Reputation: 584

Chrome has now a build-in FPS-Meter in the dev-tools. Additionally you can see the "used" and the "maximum" GPU Memory. https://developer.chrome.com/devtools/docs/rendering-settings

On my system its limited to 512 MB - I have a 4GB graphic card. So I think that is the maximum VRAM u can use on a desktop system per tab.

Upvotes: 2

Kirill Dmitrenko
Kirill Dmitrenko

Reputation: 3649

Actually, you can't query VRAM total and available sizes in OpenGL without vendor extensions. OpenGL and consequently WebGL hide that from your application. More over, WebGL manages your resources for you, uploading them to VRAM when they're needed.

If you try to create too much resources, performance of your application will degrade significantly and there is a possibility of generating of the webglcontextlost event. Also, Mozilla's WebGL implementation may generate the OUT_OF_MEMORY error on texImage2D call (it's mentioned in the "WebGL Insights" book), which, in a way, can be used as a sign of exhausting system resources.

Upvotes: 4

Related Questions