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 issues] A tale of memory leaks (act 1, scene 1) #377

Open
mjuhoor opened this issue Apr 16, 2018 · 2 comments
Open

[Memory issues] A tale of memory leaks (act 1, scene 1) #377

mjuhoor opened this issue Apr 16, 2018 · 2 comments
Assignees

Comments

@mjuhoor
Copy link

mjuhoor commented Apr 16, 2018

  • MUSIC has a problem with memory consumption. This issue is aimed at a particular
    critical bug that causes lots of memory leaks:

vtkPolyData* mesh = ...
vtkMetaSurfaceMesh* metaMesh = ...
medAbstractData* data = ...

metaMesh->SetDataSet(mesh);
data->setData(metaMesh);

Looking at the source code of medInria, one can observe that:

  • 'SetDataSet(...)' does a deep copy of the parameter
  • 'setData(...)' hides a smart pointer assignment, and thus increases the count reference.
    Therefore, both 'mesh' and 'metaMesh' should be deleted.

In numerous cases, this rule is not respected, causing multiple memory leaks.

@fcollot
Copy link

fcollot commented Apr 17, 2018

(I discussed this "live" with @mjuhoor yesterday but for the record I'll post it here)
This can be fixed by refactoring this sort of function to take smart pointers, so that the caller does not need to worry about who owns the pointer, and can delete it on their side without a problem.

@fcollot
Copy link

fcollot commented Apr 17, 2018

I'll do this as part of the architecture refactoring.

@fcollot fcollot self-assigned this Apr 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants