Problem with RhinoCommon, Intersection.MeshLine Method

Hi, I used “Rhino.geometry.intersect.intersection.MeshLine” method in C#-script component on gh for checking Ray intersection and it ran more than thousand times.
The problem was that the memory usage of the computer kept increasing during repeating calculation.
It seems the C#-script component won’t release his memory.

Does anyone know why this happen?
Thank you,

Bug in your script? Difficult to know without the script that is failing on you.

// Rolf

I’m digging up this thread.

I’ve managed to pin-point a simple scenario to replicate the problem.

private void RunScript(Mesh m, object x, ref object A)
    // Creating a List o points
    List<Point3d> points = new List<Point3d>();
    for(int i = 0;i < 100;i++){
      for(int j = 0;j < 100;j++){
        points.Add(new Point3d(i, j, 0));

    for(int j = 0;j < 100;j++){ // Looping to inflate the bug, but not needed
      for(int i = 0;i < points.Count;i++){
        Line line = new Line(points[i], points[i] + Vector3d.ZAxis);
        int[] faceIds;
        Point3d[] intersections = Rhino.Geometry.Intersect.Intersection.MeshLine(m, line, out faceIds);

… with a specific mesh (internalized), dragging the slider I can see Rhino memory usage going up by 200MB at time and never going back. I can continue until filling the whole memory of my machine and everything freezing up…
MeshLine memory (21.1 KB)

I can replicate this bug on the 2 machine I’ve tried this ^ … same thing?
I’m using Mesh Ray method as alternative…

@piac , @stevebaer


I can reproduce this in Rhino 8. I am assigning YT issue RH-78469.

1 Like