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

Hooking into tcmalloc allocations and deallocations? #44

Open
rjaber opened this issue Aug 12, 2020 · 4 comments
Open

Hooking into tcmalloc allocations and deallocations? #44

rjaber opened this issue Aug 12, 2020 · 4 comments

Comments

@rjaber
Copy link

rjaber commented Aug 12, 2020

Is there an equivalent in tcmalloc to gperftool's interfaces found in malloc_hook.h, such as AddNewHook and AddDeleteHook?

@ckennelly
Copy link
Collaborator

There have been internal discussion around alternative, more-featureful APIs for malloc hooks, but these aren't quite ready yet.

@erin2722
Copy link

erin2722 commented Mar 7, 2024

Have there been any updates/future considerations on this @ckennelly?

@AustinSchuh
Copy link

I just hit this as well, trying to update from gperftools to this version. We use these hooks to disallow allocations in hard realtime code. Any hints on where to patch in a callback until the more featureful API merges?

@torshepherd
Copy link

@AustinSchuh operator new and malloc and the like are implemented as attribute(alias(TcmallocInternalNew)) or something like that. You could alias that to your hook function instead and then call InternalNew yourself

The other option is dynamically loading with dlsym and monkey-patching the function symbol to your own function

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