Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix some memory leaks#278

Open
vdng9338 wants to merge 1 commit into
lava:master from
vdng9338:master
Open

Fix some memory leaks #278
vdng9338 wants to merge 1 commit into
lava:master from
vdng9338:master

Conversation

@vdng9338

@vdng9338 vdng9338 commented Jul 16, 2021

Copy link
Copy Markdown

In a program I wrote, I had to plot a few hundreds of matplotlib plots, and memory usage went up to 5 Gb despite calling plt::clf() and plt::close() after each plot. Removing all instances of Py_INCREF seems to solve the issue, since Py_INCREF is not needed on return values of PyObject_GetAttrString and PyObject_Call, according to https://docs.python.org/3/extending/extending.html#ownership-rules.

@vdng9338 vdng9338 deleted the branch lava:master July 28, 2021 15:16
@vdng9338 vdng9338 deleted the master branch July 28, 2021 15:16
@vdng9338 vdng9338 restored the master branch July 28, 2021 15:17

vdng9338 commented Aug 8, 2021
edited
Loading

Copy link
Copy Markdown
Author

I didn't intend to close this PR -- looks like something weird happened.

Copy link
Copy Markdown

If you're compiling with g++, compile with address sanitizer ( -fsanitize=address and link against libasan), e.g. for examples/surface.cpp

g++ -g -Wall -fsanitize=address -o surface $(python-config --includes) surface.cpp $(python-config --ldflags --embed) -lasan

This will show you all memory leaks. Before your changes, and after.

Gonzalo-Mier added a commit to Fields2Cover/matplotlib-cpp that referenced this pull request Sep 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /