Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak when constructing a hull from 4 vertices (tetrahedron) #20

Open
GNSS-Stylist opened this issue Nov 19, 2024 · 0 comments · May be fixed by #21
Open

Memory leak when constructing a hull from 4 vertices (tetrahedron) #20

GNSS-Stylist opened this issue Nov 19, 2024 · 0 comments · May be fixed by #21

Comments

@GNSS-Stylist
Copy link

When using Valgrind memory analyzer to test a project creating convex hulls from only 4 vertices it reported issues like this (this is from a test reproducing the issue):

0 bytes in 1 blocks are definitely lost in loss record 1 of 1
  in main in /path/main.c:18
  1: malloc in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so
  2: convhull_3d_build_alloc in /path/convhull_3d/convhull_3d.h:733
  3: convhull_3d_build in /path/convhull_3d/convhull_3d.h:573
  4: main in /path/main.c:18

Code generating the report above:

int main()
{
    ch_vertex vertices[4] =
    {
        { 0,  0, -1 },
        {-1, -1,  1 },
        {-1,  1,  1 },
        { 1,  0,  1 }
    };

    int nVertices = 4;
    int* faceIndices = NULL;
    int nFaces;

    convhull_3d_build(vertices, nVertices, &faceIndices, &nFaces);

    free(faceIndices);
}

Generated convex hulls (tetrahedrons) are ok.

GNSS-Stylist added a commit to GNSS-Stylist/convhull_3d that referenced this issue Nov 19, 2024
Fixes leomccormack/convhull_3d/issues/leomccormack#20

There was a tiny (0 bytes, but allocating 0 bytes likely still uses memory for bookkeeping) that was also reported by Valgrind memory analyzer. This only happened when creating a hull from 4 vertices (tetrahedron). The hulls were ok and this fix doesn't affect those.
GNSS-Stylist added a commit to GNSS-Stylist/GNSS-Stylus that referenced this issue Nov 19, 2024
Added this due to a tiny (0 bytes alloc) memory leak in convhull_3d,
just to test if the generated hulls are ok (they are).

See:
leomccormack/convhull_3d#20
leomccormack/convhull_3d#21

Will commit a fix to the memory leak in a separate commit soon.
GNSS-Stylist added a commit to GNSS-Stylist/GNSS-Stylus that referenced this issue Nov 19, 2024
There was a tiny (0 bytes, but allocating 0 bytes likely still uses
memory for bookkeeping) memory leak that was also reported by Valgrind
memory analyzer. This only happened when creating a hull from 4 vertices
(tetrahedron). The hulls were ok and this fix doesn't affect those.

From:
leomccormack/convhull_3d#20
leomccormack/convhull_3d#21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant