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

Feature Request: Supporting bulk-deallocation in memory profiling #917

Open
simonvanbernem opened this issue Oct 25, 2024 · 2 comments
Open

Comments

@simonvanbernem
Copy link
Contributor

simonvanbernem commented Oct 25, 2024

I often use pool allocators in my programs, which allow for many small allocations but ignore calls to free these allocations, because they will all be freed at once after it is known that the allocated objects are no longer needed. This can simplify and speed up memory management tremendously in certain cases, as you simply don't need to call free until the end.

(The allocator basically behaves like and std::vector in that you can push_back many times, but when destroying the vector, you don't need to shrink it back to 0, you just release the entire memory range )

Trying to instrument these allocators for tracy's memory profiling is a problem however, because there is only a single free event for many allocations. To satisfy the 1-to-1 requirement that tracy has, the allocator would need to keep a list of allocations, which negates the advantages of these types of allocators. But if I don't do this, all allocations of this allocator will appear as leaks (which is bad), AND if the memory allocator is reset, but reuses the memory, tracy will see that as two allocations for the same address without a free and stop the profile (which is worse).

To support memory profiling for this kind of allocation scheme easily, it would be great if tracy had a TracyCFreeRange function in addition to the existing TracyCFree function, that took an address and size and would automatically treat all live allocations in the provided memory range as deallocated.

@wolfpld
Copy link
Owner

wolfpld commented Oct 25, 2024

Duplicate of #915.

@wolfpld wolfpld closed this as completed Oct 25, 2024
@simonvanbernem
Copy link
Contributor Author

I don't think it's a duplicate. #915 is about freeing the entirety of a pool, whereas having a address + size variant would allow to partially free a pool (which I failed to mention in my initial description though).

That use case is more niche, but I have done this with stack allocators.

@wolfpld wolfpld reopened this Oct 25, 2024
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

2 participants