PyMeshLab icon indicating copy to clipboard operation
PyMeshLab copied to clipboard

Memory Leak get_hausdorff_distance?

Open psicomante opened this issue 2 years ago • 2 comments

Hello,

Thanks for this awesome library. We're using it to do some mesh processing. We have some issues using hausdorff distance. The script keeps increasing used memory, without any drop. We suspect some memory leak, here the code. Do you have any clue?

@profile
def cal_dist(path1, path2):
    ms = pymeshlab.MeshSet()
    ms.load_new_mesh(path1)
    ms.load_new_mesh(path2)
    res_dict = ms.apply_filter('get_hausdorff_distance', targetmesh=1, sampledmesh=0, maxdist=pymeshlab.Percentage(100), samplevert=True)
    ms.clear()
    del ms
    
    r = res_dict['RMS']
    return r

objs = collect_obj_name("./dataset/perf_test")
for i in range(500):
    i1 = math.floor(random.random()*len(objs))
    i2 = math.floor(random.random()*len(objs))
    # print(i1, i2)
    d = cal_dist(objs[i1], objs[i2])
    # print(d)

The used memory has a peak at ~200mb (monotonically increasing).

Thanks.

psicomante avatar Mar 07 '22 17:03 psicomante

Hi, sorry for the late reply. Are your meshes obj files? I can confirm memory leaks, but they are related to the obj loader and not to the hausdorff distance computation.

alemuntoni avatar Apr 26 '22 10:04 alemuntoni

Hi Ale, don't worry.

Yep, the meshes are obj files. Thanks for the reply.

psicomante avatar May 05 '22 08:05 psicomante