Comments (3)
Just to add
#include <dlfcn.h>
#include <execinfo.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <malloc.h>
void *
malloc (size_t size)
{
const char *message = "malloc called\n";
write (STDOUT_FILENO, message, strlen (message));
void *next = dlsym (RTLD_NEXT, "malloc");
return ((__typeof__ (malloc) *) next) (size);
}
int
main (void)
{
/* This calls malloc. */
puts ("First call to backtrace.");
void *buffer[10];
backtrace (buffer, 10);
puts ("First call to backtrace.");
backtrace (buffer, 10);
puts ("First call to backtrace.");
backtrace (buffer, 10);
/* This does not. */
puts ("Second call to backtrace.");
backtrace (buffer, 10);
malloc(10);
}
Compiled with
g++ -g pop.cpp -lstdc++ -Wl,--no-as-needed -ldl -ltcmalloc -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
Got output
malloc called
malloc called
malloc called
malloc called
malloc called
malloc called
malloc called
malloc called
malloc called
malloc called
malloc called
malloc called
malloc called
First call to backtrace.
malloc called
First call to backtrace.
First call to backtrace.
Second call to backtrace.
malloc called
from tcmalloc.
TCMalloc does not support being dynamically loaded in this fashion.
I think the behavior for whether backtrace
calls malloc
or not is a property of your libc, rather than TCMalloc itself.
from tcmalloc.
Is there any feature or provision that can be added to capture backtrace of each allocation and maintain the same in memory with extra few bytes in real time ?. We are looking for some implementation on the same lines.
from tcmalloc.
Related Issues (20)
- Disabling tcmalloc cache HOT 2
- OSS-Fuzz issue 65919 HOT 1
- OSS-Fuzz issue 66172 HOT 1
- MADV_COLLAPSE
- Failed to build tcmalloc, Error info: junk at end of line HOT 1
- Quick start guide broken
- How to access tcmalloc MallocExtensions? HOT 1
- Help with heap profiler. HOT 1
- Compiling Issues on aarch64 HOT 2
- OSS-Fuzz issue 67559
- GuardedPageAllocator appears in stack trace when ActivateGuardedSampling() has not been called HOT 10
- OSS-Fuzz issue 68039 HOT 1
- OSS-Fuzz issue 68082
- Per cpu cache of bigger sizes HOT 7
- Compiler error HAVE_SBRK HOT 1
- Compilation Error with tcmalloc: ‘static constexpr bool absl::lts_20230125::base_internal::SpinLock::IsCooperative’ is private within this context HOT 1
- Use more memory than default c++ HOT 1
- tcmalloc cannot optimize dynamic memory allocation caused by std::vector. HOT 11
- GWP-ASan may report segv in multi-thread when write_overflow/double_free detected at free?
- Is there a debugging document of tcmalloc? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tcmalloc.