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

Support for user allocator #55

Closed
Pierre-Terdiman opened this issue Feb 23, 2022 · 7 comments
Closed

Support for user allocator #55

Pierre-Terdiman opened this issue Feb 23, 2022 · 7 comments

Comments

@Pierre-Terdiman
Copy link

We already discussed it so I know it's on your list, but I'd like to officially ask for adding a "user allocator". The goal would be to allocate all objects (not just the temporary ones) thought this allocator, so that we can accurately track memory usage.

Thanks!

@jankrassnigg
Copy link
Contributor

Would like to see this as well. Might mean that you'd need to get rid of using std::vector and use a custom array class.

@jrouwe
Copy link
Owner

jrouwe commented Feb 25, 2022

I was planning on using the allocator class that you can provide to std::vector, maybe I'll create my own container classes at some point in the future (for now it is not really in the way as it is mostly used for long term storage).

@urosidoki
Copy link

I have a problem that might be related to this (not sure). I have my own custom allocator where I keep track of memory, but when I am shutting down the app, I got tons of memory leaks from the memory allocated during the call to JPH::RegisterTypes();
Would be nice to be able to have a certain level of control over when I do want to deallocate that memory.

@jrouwe
Copy link
Owner

jrouwe commented May 3, 2022

Can you try #146 and call JPH::Factory::sInstance.Clear()? My guess is that your leak detection code runs before the static destructors are called. I'm not 100% sure that this will fix it as some STL implementations seem to allocate memory even if the map is empty.

@jrouwe
Copy link
Owner

jrouwe commented May 10, 2022

I did some more work on #146 and removed most of the memory allocated by global constructors and made the application responsible for newing/destroying the factory. There are a couple of allocations left by the global constructors, most notably the SphereShape used by Body::sFixedToWorld, but I believe that that should not be an issue for your particular case.

@jrouwe
Copy link
Owner

jrouwe commented Jun 14, 2022

Merged #183.

@jrouwe jrouwe closed this as completed Jun 14, 2022
@sherief
Copy link
Contributor

sherief commented Jul 30, 2022

YAY!

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

5 participants