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 leakage during optimization #30

Open
SNMS95 opened this issue Sep 27, 2023 · 2 comments
Open

Memory leakage during optimization #30

SNMS95 opened this issue Sep 27, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@SNMS95
Copy link
Collaborator

SNMS95 commented Sep 27, 2023

It seems there is come memory leakage somewhere.
It can be clearly seen if the topopt example is run and you monitor the memory. It is steadily increasing. This results in OOM-KILL events on HPCs.

  1. Part of the reason is not destroying the PETSc objects. This is easily fixed.
  2. We need some tool to do this everytime we make changes [Scalene perhaps?]
  3. There is another source that I have not been able to pinpoint yet
@SNMS95 SNMS95 added the bug Something isn't working label Sep 27, 2023
@SNMS95
Copy link
Collaborator Author

SNMS95 commented Sep 28, 2023

Add to end:

    if use_petsc:
        A_fn.destroy()
    else:
        del A_fn
    del dofs
    del res_vec
    gc.collect()
    return sol

b.

def petsc_solve(A, b, ksp_type, pc_type, direct_solve=True):

    # Delete PETSc objects
    ksp.destroy()
    rhs.destroy()
    y.destroy()
    A.destroy()
    result = x.getArray()
    x.destroy()
    gc.collect()
    return result

c.

def get_A_fn(problem, use_petsc):

    problem.A_sp_scipy_diag = A_sp_scipy.diagonal()
    ...
    del A_sp_scipy
    del A_sp

@SNMS95
Copy link
Collaborator Author

SNMS95 commented Sep 28, 2023

I think we should make garbage collection as a standard practice when collaborating

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant