Skip to content

Instantly share code, notes, and snippets.

@bsergean
Forked from sifangli/CMakeLists.txt
Created January 24, 2022 20:04
Show Gist options
  • Save bsergean/caa500781bce87bf2918dc8ff4792bde to your computer and use it in GitHub Desktop.
Save bsergean/caa500781bce87bf2918dc8ff4792bde to your computer and use it in GitHub Desktop.
Test jemalloc memory profile
cmake_minimum_required(VERSION 3.17)
project(MyCppTest)
set(CMAKE_CXX_STANDARD 20)
include_directories(/tmp/jemalloc/include)
link_directories(/tmp/jemalloc/lib)
add_library(jemalloc SHARED IMPORTED)
add_executable(MyCppTest src/Main.cpp)
#include <iostream>
#include <vector>
#include <jemalloc/jemalloc.h>
#include <stdlib.h>
using namespace std;
int main() {
vector<string> V1 = { "A", "B" };
for ( auto & v1 : V1 ) {
std::cout << "-->" << v1 << "\n";
}
const char *fileName = "heap_info.out";
je_mallctl("prof.dump", NULL, NULL, &fileName, sizeof(const char *));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment