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 in generate_surface_reconstruction_screened_poisson() -- pymeshlab==2023.12.post2 #1554

Open
eskjorg opened this issue Nov 20, 2024 · 0 comments

Comments

@eskjorg
Copy link

eskjorg commented Nov 20, 2024

Ubuntu 22.04.4 LTS
python==3.11
pymeshlab=='2023.12.post2'
numpy=='1.26.4'

Though this is PyMeshLab, the leak is likely in the main repository.

Repro script:

import os
import numpy as np
import psutil
import pymeshlab as pm
from memory_profiler import profile

NUM_THREADS = 8
NUM_ITERATIONS = 20

def generate_sphere_point_cloud(radius=1.0, num_points=100000):
    theta = np.random.uniform(0, 2 * np.pi, num_points)
    phi = np.random.uniform(0, np.pi, num_points)

    x = radius * np.sin(phi) * np.cos(theta)
    y = radius * np.sin(phi) * np.sin(theta)
    z = radius * np.cos(phi)

    points = np.vstack((x, y, z)).T
    return points

def print_memory_usage(process):
    mem_info = process.memory_info()
    print(
        "MEMORY USAGE: "
        f"RSS={mem_info.rss / (1024 * 1024):.2f} MB, "
        f"VMS={mem_info.vms / (1024 * 1024):.2f} MB"
    )

# @profile
def poisson(points):
    ms = pm.MeshSet()
    m = pm.Mesh(points)
    ms.add_mesh(m, "sphere")
    ms.compute_normal_for_point_clouds(k=20)
    ms.generate_surface_reconstruction_screened_poisson(
        depth=9, pointweight=0, samplespernode=5, cgdepth=9, threads=NUM_THREADS
    )
    m = ms.current_mesh()
    ms.clear()
    ms.clear_filter_script()

def test_memory_leak():
    process = psutil.Process(os.getpid())
    points = generate_sphere_point_cloud()
    for _ in range(NUM_ITERATIONS):
        print_memory_usage(process)
        poisson(points)
    print_memory_usage(process)


if __name__ == "__main__":
    test_memory_leak()
@eskjorg eskjorg changed the title memory leak in generate_surface_reconstruction_screened_poisson -- pymeshlab==2023.12.post2 memory leak in generate_surface_reconstruction_screened_poisson() -- pymeshlab==2023.12.post2 Nov 20, 2024
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

No branches or pull requests

1 participant