-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add a simple memory profiler #93
Comments
I'm going to add a simple interface that lets you pass in callbacks that will be called on alloc/dealloc. That lets users of the library implement their own tracking, with zero overhead if you don't use it. |
Assume PhysX does support overriding their allocator also? Could be quite nice to support overriding it and connect it to the Rust global memory allocator (or rather: A Rust memory allocator of the users choosing) through the standard trait or a custom one. This is what we use in our engine and great to have most heap allocations in the same main allocator. Assuming the interfaces and needs are similar. |
Yeah, we can also replace the whole allocator. Can try that instead. Physx does send in a bit of extra metadata that we really want to track separately (as Emil mentions), but can then pass through to a Rust alloc. |
Cool, worth a shot |
I implemented a super rudimentary tracking allocator here. |
The allocation name feature actually kinda mostly works in release mode, you just have to call In our application we implemented a tracker on top of the trampoline I added in #94 , actually very similar to yours. |
I want to know how much memory PhysX is using.
It seems like
physx-rs
could overloadPxAllocatorCallback
to add simple tracking of used memory. This could then be queried likescene.bytes_allocated()
. I would assume such an overload would have so little overhead that it wouldn't need to be feature-gated, but if it does have overhead then maybe a simpleSceneBuilder
flag to turn it on could be considered.PxAllocatorCallback
also supplies atypeName
for the allocated resource, so in the future one could consider returning a more detailedHashMap<String, usize>
describing what is using memory, though I am not sure if such detail would be useful in practice.The text was updated successfully, but these errors were encountered: