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

V8 GC does not know if PyObjects grow after initialization #74

Open
mmomtchev opened this issue Jan 20, 2023 · 0 comments
Open

V8 GC does not know if PyObjects grow after initialization #74

mmomtchev opened this issue Jan 20, 2023 · 0 comments

Comments

@mmomtchev
Copy link
Owner

The V8 GC has a complex algorithm that decides when it is going to make a collection run and this requires tracking of the allocated memory. Currently pymport reports only the size of objects it has referenced and does only once.

In particular these two cases can be problematic:

  • Allocating small Python objects, then growing them - for example a dict or a list that gradually becomes huge - V8 won't be aware of the size of this object and won't be in a hurry to free it when it is no longer referenced
  • Python subroutines allocate a large number of Python objects that are never seen by V8 - V8 may continue allocating memory beyond its administrative limits

These problem do not cause leaks - as the memory is still tracked - it is simply not correctly included in the GC statistics.

Alas, solving these problems would require instrumenting Python's allocator (which is costly) and there is no possible solution compatible with worker_threads - as all V8 threads share the same Python instance - it won't be possible to know whose account is to be charged when allocating memory.

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