Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

PyObjects are leaking memory when used in a synchronous loop #3

Closed
mmomtchev opened this issue Nov 3, 2022 · 2 comments · Fixed by #334
Closed

PyObjects are leaking memory when used in a synchronous loop #3

mmomtchev opened this issue Nov 3, 2022 · 2 comments · Fixed by #334

Comments

@mmomtchev
Copy link
Owner

mmomtchev commented Nov 3, 2022

This code is leaking memory:

for (let i = 0; i < 1000; i++) {
  const a = PyObject.list([1]);
  a.get('__getitem__');
}
@mmomtchev mmomtchev changed the title Method PyObject.get is leaking function descriptors PyObjects are leaking memory when used in a synchronous loop Nov 3, 2022
@mmomtchev mmomtchev added the wontfix This will not be worked on label Nov 3, 2022
@mmomtchev
Copy link
Owner Author

Alas, this is a general Node.js problem which does not have a simple solution: nodejs/node-addon-api#1140

The problem is not that serious as it might appear because:

  • Server code is never synchronous
  • Client code usually does not run forever

Still, if doing very heavy computation that requires periodic cleanup of stale objects, the two profiling targets have been transformed to async code - which completely solves this problem

mmomtchev added a commit that referenced this issue Nov 3, 2022
@mmomtchev
Copy link
Owner Author

It seems that there has been progress on this issue in Node.js but it requires that the addon explicitly supports the new code.

@mmomtchev mmomtchev removed the wontfix This will not be worked on label May 1, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant