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

Tracy rpmalloc allocating and leaving 4mb heaps on every thread #983

Open
alecazam opened this issue Feb 15, 2025 · 1 comment
Open

Tracy rpmalloc allocating and leaving 4mb heaps on every thread #983

alecazam opened this issue Feb 15, 2025 · 1 comment

Comments

@alecazam
Copy link

So I finally got our threads to call SetThreadName in tracy, and was surprised to find 400MB of memory piling up (80MB base + 4mb x 80 threads = 400). Every 40 threads created/destroy would add 4MB x 40 thread = 160mb). This is a lot for mobile apps, or apps with large numbers of threads.

Seems that each tracy_malloc call, in this case allocating a 32B or less name, then causes a rpmalloc heap/span to get created. These are never released. So I found the ThreadExitHandler (not documented), and that is required to do the rpmalloc finalize before a thread is exited.

So seems like these changes would help:

  1. There should be some control over the size of each rpmalloc heap
  2. SetThreadName shouldn't use tracy_malloc. App may never send any timestamps. Only create heaps if server connects and receives timestamps from a thread.
  3. A flag to disable use of rpmalloc, and use the system or custom malloc.
  4. Document these heaps and need for cleanup via ThreadExitHandler dtor.
@alecazam
Copy link
Author

alecazam commented Feb 16, 2025

Looks like there's this, so that could be used to lower the memory page size. But no early call to this with static init creating threads and initing the rpmalloc with a null config.

rpmalloc_initialize_config

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