0

HelixToolkit.Wpf 'System.OutOfMemoryException' was thrown

Anonymous 10 years ago 0
This discussion was imported from CodePlex

Moez_rebai wrote at 2014-07-16 14:28:

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,

everytimer wrote at 2014-07-16 21:22:

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

Moez_rebai wrote at 2014-07-17 09:25:

Thanks for your reply, but did you know how to create mesh from Positions and TriangleIndices using LinesVisual3D .

BogusException wrote at 2014-07-18 00:08:

@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
:)