This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// g++ -L<path-to-libtcmalloc.so> -ltcmalloc memory-test.cc | |
// env LD_LIBRARY_PATH=<path-to-libtcmalloc.so>b HEAPPROFILE=<prefix-to-output-files HEAP_PROFILE_INUSE_INTERVAL=1048576 ./a.out | |
#include <iostream> | |
#include <cstdlib> | |
#include <cstdio> | |
using namespace std; | |
class Sub { | |
public: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Test code of http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=6080813. | |
// Actually, it doesn't require to make type_identifier_to_string. | |
// The mapping can be obtained from a linker. | |
#include <map> | |
#include <string> | |
#include <typeinfo> | |
std::map<void *, char *> pointer_to_type_identifier; | |
std::map<void *, const std::type_info*> pointer_to_type_info; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// g++ -I/.../google-coredumper/include -L/.../google-coredumper/lib -lcoredumper core_dumper.cc | |
// env LD_LIBRARY_PATH=/.../google-coredumper-working/lib ./a.out | |
#include <google/coredumper.h> | |
int main() { | |
WriteCoreDump("hyanore.core"); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class parent_t { | |
public: | |
void print_it() { | |
local_print(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
void* backed_malloc(size_t size) __attribute__ ((weak, alias ("malloc"))); | |
void* hook_malloc(size_t size) { | |
printf("%ld\n", size); | |
return backed_malloc(size + 1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iterator> | |
#include <iostream> | |
#include <map> | |
#include <unordered_map> | |
#include <utility> | |
#include <vector> | |
typedef unsigned long long uint64; | |
class ExclusiveClosedRange { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
class Parent { | |
public: | |
int x; | |
virtual void print() { std::cout << "Parent" << std::endl; } | |
}; | |
class Child: public Parent { | |
public: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <typeinfo> | |
class Base { | |
public: | |
Base() : x_(0) {} | |
virtual void print() { std::cout << "Base" << std::endl; } | |
private: | |
int x_; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* stdout compiled without -fallocated-type-in-operator-new: | |
* > 0 | |
* > 2 | |
* > 9 | |
* > 5 | |
* | |
* stdout compiled without -fallocated-type-in-operator-new: | |
* > Allocated at 0xb80010 as an instance of 5Klass | |
* > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstddef> | |
void* operator new(size_t size, int dummy) { | |
return ::operator new(size); | |
} | |
class Class { | |
public: | |
Class() : x_(0) {} | |
void* operator new(size_t size) { |
OlderNewer