HelixToolkit.Wpf 'System.OutOfMemoryException' was thrown

Jul 16, 2014 at 12:28 PM
Edited Jul 16, 2014 at 12:33 PM
Hello.
Sometimes i tried to add a Mesh3D to the Mesh property of a MeshVisual3D, I get this exception:
'System.OutOfMemoryException' was thrown'

The code
            MeshGeometry3D modeltodraw = new MeshGeometry3D();
            // fill modeltodraw 
            var originalMesh = new Mesh3D(modeltodraw.Positions, modeltodraw.TriangleIndices);
            var bounds = originalMesh.GetBounds();
            var l = Math.Max(bounds.Size.X, Math.Max(bounds.Size.Y, bounds.Size.Z));
            model1.Mesh = null;
            try
            {
                model1.Mesh = originalMesh;
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show( ex.Message);
            }
The Mesh3D seems to be a little bit huge :

Edges Count = 125631
Faces Count = 612956
Vertices Count = 125631

Any idea why i got this exception

Best Regards,
Jul 16, 2014 at 7:22 PM
I haven't used MeshVisual3D yet but I think it creates a geometry from your mesh. The geometry is made with cylinders and spheres for the vertices and edges. So each edge/vertex converts into several (maybe 10-50 times more complex). So I think it's normal for you to get that exception as your computer can't handle it.

If you really need to see your mesh I recommend LinesVisual3D. It's not the best but you will be able to see your huge mesh with that. Good luck
Jul 17, 2014 at 7:25 AM
Thanks for your reply, but did you know how to create mesh from Positions and TriangleIndices using LinesVisual3D .
Jul 17, 2014 at 10:08 PM
@Moez_rebai,

Do you run Anvir, or even Task Manager to see which resources are expended? I think there is a memory debugger built into VS I read about, but never used. I use the threading one all the time, though. I think you can 'profile' your app, and it will show you over time how it is performing.

Check out the "ANALYZE" pull-down menu in VS, too!

pat
:)