HI,

this is a letter posted on the PV3d list showing how a developer
modded PV3D garbage collection, even though its a different engine,
and might not apply, I thought I'd paste it here in case anyone else
wants to look at the techniques;

294913 Number3D (around 30% of total memory usage of the game)
> 96649 Vertex3DInstance (15% of total memory usage)
> 95508 Dictionaries (10% of total memory usage)
> 95433 Vertex3D (20% of total memory usage)
> =
> 582503 objects in memory for our golfers geometry!
>
> Given how flash has a mark-sweep garbage collector, this was giving some
> interesting performance issues related to garbage collection.
>
> So the steps we took to optimise it were:
> - Each Vertex3D object has a Dictionary instance that is used compute
> normals. The normals computed happens once, however the dictionary was not
> not free'd. So we Saved ~90.000 Dictionary objects there
>
> - Vertex3DInstance has an unused normal instantied to 0,0,0, i.e. a
> Number3D, it's never referenced or used outside Vertex3DInstance removed
> this: removed ~90.000 Number3D instances
>
> - Vertex3D caches a "position" as Number3D that is used once for Normal
> calculation, this was never freed. I removed this and just used original
> x,y,z. saved as i did not see a need for this indirection. around 90.000
> further Number3D instances removed
>
> - Not sure about the safety of this one, however the normal in Vertex3D was
> not referenced anywhere other than being initialised. So in the end i got
> rid of this. Another 90.000 more Number3D instances saved
>
> - last but not least, every Vertex3D has a Vertex3DInstance object used for
> the rendered onscreen position. Again, this indirection did not seem
> neceserry, so I merged these 2 classes into 1 and same object rather than
> child object which saved alot more unneeded object instances and references
>
> So these combined optimisations ended us up with:
> - 96649 instances of Vertex3D (all vertexes for all frames naturally)
> - 7398 Number3D instances
>
> This ended up saving us nearly 500.000 object instances and halving our
> apps
> memory usage (reported by flex profiler) from 30MB to 15MB. It also greatly
> improved performance of garbage collection.
>
> You can see a summary from the profiling here:
> http://www.kimdanielarthur.com/tmp/papervision_optimise.gif
>
> Hopefully useful if anyone runs into similar behaviour!
>
> Kim Daniel Arthur
>
> ps.
> Thanks again for a great 3D library its really brought extra life to our
> games
>

Reply via email to