"Out of memory" errors

172 views
Skip to first unread message

Evgeny Demidov

unread,
May 13, 2015, 4:17:23 AM5/13/15
to WebGL Dev List
Testing page "Path" renders 20 non-instanced (identical yet) procedural
maple trees
http://www.ibiblio.org/e-notes/Splines/tree/path.htm
The script uses about 20*16MB = 320MB of GPU memory to store indexed
vertex data
var num = 20
pt = new Float32Array(num*2000000); ind = new Uint32Array(num*2000000);
It is stable in Chrome and IE (after 10 reloads) but not very stable in
my Firefox (Windows 7, Intel I5, 4MB memory, Geforse 560). After ~5
reloads (in succession) I get "out of memory" error.

I've found not very encouraging answer "Can I know how much VRAM I can use?"
http://codeflow.org/entries/2013/feb/22/how-to-write-portable-webgl/#can-i-know-how-much-vram-i-can-use

But what shall I suppose now as optimal safe memory size for desktop
(e.g. 1/2 of 1GB GPU memory) or mobile devices (1/4 of 2MB memory), to
make really Mighty Maple (or grove) for Web?

Evgeny

Won

unread,
May 13, 2015, 11:51:57 AM5/13/15
to webgl-d...@googlegroups.com
Why are there the same number of indices and vertices? Does this mean there is no vertex sharing? That will hurt both memory use and transform throughput. Why not instancing? Each tree seems like enough triangles so that doing a draw call per tree isn't bad at all.



Evgeny

--
You received this message because you are subscribed to the Google Groups "WebGL Dev List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webgl-dev-lis...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kenneth Russell

unread,
May 13, 2015, 7:43:41 PM5/13/15
to webgl-d...@googlegroups.com
Using the ANGLE_instanced_arrays extension is a good suggestion. It
should be widely supported and significantly reduce your resource
usage.

Separately, Evgeny, it isn't clear from your email whether you're
running out of JavaScript heap memory, or video memory on the graphics
card. I couldn't reproduce your report on Firefox 37.0.2 on Windows
8.1. If you're running out of GPU resources, you may want to file a
bug against Firefox's WebGL implementation. In Chrome, when the user
navigates away from a page containing WebGL, or reloads such a page,
the GPU resources are deleted immediately. Otherwise they'll likely
only be reclaimed when the JavaScript engine collects garbage, and
this isn't guaranteed to happen promptly.

-Ken

Evgeny Demidov

unread,
May 14, 2015, 12:24:20 AM5/14/15
to webgl-d...@googlegroups.com
5/13/2015 6:51 PM, Won:
Why are there the same number of indices and vertices? Does this mean there is no vertex sharing? That will hurt both memory use and transform throughput.
they differ a little. On regular grid each point enters in 6 triangles, therefore so many indices.


Why not instancing? Each tree seems like enough triangles so that doing a draw call per tree isn't bad at all.
Sorry, I wasn't very clear. It is just a test - can one make (for Web) a grove of different trees or just "bonsai" (or "ikebana" :) See e.g. "Mighty maple tree" (~80MB)
http://www.ibiblio.org/e-notes/Splines/tree/mighty_maple.htm
and all the same - is it mighty enough? :)

Evgeny

Evgeny Demidov

unread,
May 14, 2015, 1:15:45 AM5/14/15
to webgl-d...@googlegroups.com
5/14/2015 2:43 AM, Kenneth Russell:
> Using the ANGLE_instanced_arrays extension is a good suggestion. It
> should be widely supported and significantly reduce your resource
> usage.
yes I know, but 40 instanced and non-instanced apple trees had the same
fps (quite acceptable).
> Separately, Evgeny, it isn't clear from your email whether you're
> running out of JavaScript heap memory, or video memory on the graphics
> card. I couldn't reproduce your report on Firefox 37.0.2 on Windows
> 8.1. If you're running out of GPU resources, you may want to file a
> bug against Firefox's WebGL implementation. In Chrome, when the user
> navigates away from a page containing WebGL, or reloads such a page,
> the GPU resources are deleted immediately. Otherwise they'll likely
> only be reclaimed when the JavaScript engine collects garbage, and
> this isn't guaranteed to happen promptly.
I think they have enough of work without my trees :)

congratulations. I get 40 trees (640MB VRAM) in Chrome.
Windows still swapped something (more 5 min) after 1280MB (> 1GB GPU
VRAM) script,
but I can close Chrome and PC (mail program) is stable.

On Nexus 10 Chrome is crashed (once, no extensive tests) by 320 MB
script, but is stable for 10 trees (160MB).
I think 10 trees is the "golden mean" :) But "Mighty maple" (5 "trees",
80MB)
http://www.ibiblio.org/e-notes/Splines/tree/mighty_maple.htm
may be too heavy for 1MB RAM smartphones. Not sure if I shall put it on
the main "maple" page and
shall I warn "Caution! Mighty Maple may hurt you" (really, this was my
main question)

Evgeny

Won

unread,
May 14, 2015, 1:24:51 PM5/14/15
to webgl-d...@googlegroups.com
Here's a different thought. It seems these trees are procedurally generated using something like a L-system (something that is representable as a recursive scenegraph). Is it possible to reuse the same geometry at different levels of the recursion?

Evgeny Demidov

unread,
May 15, 2015, 12:53:22 AM5/15/15
to webgl-d...@googlegroups.com
5/14/2015 8:24 PM, Won
> Here's a different thought. It seems these trees are procedurally
> generated using something like a L-system (something that is
> representable as a recursive scenegraph). Is it possible to reuse the
> same geometry at different levels of the recursion?
yes, for simplicity mighty maple is made of 5 identical branches.
Therefore it is possible to optimize memory usage by instanced branches.
But I'd like to try to make growing maple:
1. make (recursive) tree with different "ages" (1,2..8.. years, instead
of dissection "level" now)
2. make growth animation (with leaves fading and falling (what can I do
with intersection detection during fall?))
3. make true growth simulation (not just fixed recursive rules)

Evgeny
Reply all
Reply to author
Forward
0 new messages