Last active
January 24, 2022 20:06
-
-
Save sifangli/64b4df7af2bbc4247ddf249d4b3df9f3 to your computer and use it in GitHub Desktop.
Test jemalloc memory profile
This file contains hidden or 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
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) |
This file contains hidden or 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 <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; | |
} |
This file contains hidden or 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
# CMAKE generated file: DO NOT EDIT! | |
# Generated by "Unix Makefiles" Generator, CMake Version 3.20 | |
# Default target executed when no arguments are given to make. | |
default_target: all | |
.PHONY : default_target | |
# Allow only one "make -f Makefile2" at a time, but pass parallelism. | |
.NOTPARALLEL: | |
#============================================================================= | |
# Special targets provided by cmake. | |
# Disable implicit rules so canonical targets will work. | |
.SUFFIXES: | |
# Disable VCS-based implicit rules. | |
% : %,v | |
# Disable VCS-based implicit rules. | |
% : RCS/% | |
# Disable VCS-based implicit rules. | |
% : RCS/%,v | |
# Disable VCS-based implicit rules. | |
% : SCCS/s.% | |
# Disable VCS-based implicit rules. | |
% : s.% | |
.SUFFIXES: .hpux_make_needs_suffix_list | |
# Command-line flag to silence nested $(MAKE). | |
$(VERBOSE)MAKESILENT = -s | |
#Suppress display of executed commands. | |
$(VERBOSE).SILENT: | |
# A target that is always out of date. | |
cmake_force: | |
.PHONY : cmake_force | |
#============================================================================= | |
# Set environment variables for the build. | |
# The shell in which to execute make rules. | |
SHELL = /bin/sh | |
# The CMake executable. | |
CMAKE_COMMAND = "/Users/sifangli/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-0/212.5080.54/CLion.app/Contents/bin/cmake/mac/bin/cmake" | |
# The command to remove a file. | |
RM = "/Users/sifangli/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-0/212.5080.54/CLion.app/Contents/bin/cmake/mac/bin/cmake" -E rm -f | |
# Escaping for special characters. | |
EQUALS = = | |
# The top-level source directory on which CMake was run. | |
CMAKE_SOURCE_DIR = /Users/sifangli/ws/SfTmp/CppTest | |
# The top-level build directory on which CMake was run. | |
CMAKE_BINARY_DIR = /Users/sifangli/ws/SfTmp/CppTest/cmake-build-debug | |
#============================================================================= | |
# Targets provided globally by CMake. | |
# Special rule for the target rebuild_cache | |
rebuild_cache: | |
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." | |
"/Users/sifangli/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-0/212.5080.54/CLion.app/Contents/bin/cmake/mac/bin/cmake" --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) | |
.PHONY : rebuild_cache | |
# Special rule for the target rebuild_cache | |
rebuild_cache/fast: rebuild_cache | |
.PHONY : rebuild_cache/fast | |
# Special rule for the target edit_cache | |
edit_cache: | |
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "No interactive CMake dialog available..." | |
"/Users/sifangli/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-0/212.5080.54/CLion.app/Contents/bin/cmake/mac/bin/cmake" -E echo No\ interactive\ CMake\ dialog\ available. | |
.PHONY : edit_cache | |
# Special rule for the target edit_cache | |
edit_cache/fast: edit_cache | |
.PHONY : edit_cache/fast | |
# The main all target | |
all: cmake_check_build_system | |
$(CMAKE_COMMAND) -E cmake_progress_start /Users/sifangli/ws/SfTmp/CppTest/cmake-build-debug/CMakeFiles /Users/sifangli/ws/SfTmp/CppTest/cmake-build-debug//CMakeFiles/progress.marks | |
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 all | |
$(CMAKE_COMMAND) -E cmake_progress_start /Users/sifangli/ws/SfTmp/CppTest/cmake-build-debug/CMakeFiles 0 | |
.PHONY : all | |
# The main clean target | |
clean: | |
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 clean | |
.PHONY : clean | |
# The main clean target | |
clean/fast: clean | |
.PHONY : clean/fast | |
# Prepare targets for installation. | |
preinstall: all | |
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall | |
.PHONY : preinstall | |
# Prepare targets for installation. | |
preinstall/fast: | |
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall | |
.PHONY : preinstall/fast | |
# clear depends | |
depend: | |
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 | |
.PHONY : depend | |
#============================================================================= | |
# Target rules for targets named MyCppTest | |
# Build rule for target. | |
MyCppTest: cmake_check_build_system | |
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 MyCppTest | |
.PHONY : MyCppTest | |
# fast build rule for target. | |
MyCppTest/fast: | |
$(MAKE) $(MAKESILENT) -f CMakeFiles/MyCppTest.dir/build.make CMakeFiles/MyCppTest.dir/build | |
.PHONY : MyCppTest/fast | |
src/Main.o: src/Main.cpp.o | |
.PHONY : src/Main.o | |
# target to build an object file | |
src/Main.cpp.o: | |
$(MAKE) $(MAKESILENT) -f CMakeFiles/MyCppTest.dir/build.make CMakeFiles/MyCppTest.dir/src/Main.cpp.o | |
.PHONY : src/Main.cpp.o | |
src/Main.i: src/Main.cpp.i | |
.PHONY : src/Main.i | |
# target to preprocess a source file | |
src/Main.cpp.i: | |
$(MAKE) $(MAKESILENT) -f CMakeFiles/MyCppTest.dir/build.make CMakeFiles/MyCppTest.dir/src/Main.cpp.i | |
.PHONY : src/Main.cpp.i | |
src/Main.s: src/Main.cpp.s | |
.PHONY : src/Main.s | |
# target to generate assembly for a file | |
src/Main.cpp.s: | |
$(MAKE) $(MAKESILENT) -f CMakeFiles/MyCppTest.dir/build.make CMakeFiles/MyCppTest.dir/src/Main.cpp.s | |
.PHONY : src/Main.cpp.s | |
# Help Target | |
help: | |
@echo "The following are some of the valid targets for this Makefile:" | |
@echo "... all (the default if no target is provided)" | |
@echo "... clean" | |
@echo "... depend" | |
@echo "... edit_cache" | |
@echo "... rebuild_cache" | |
@echo "... MyCppTest" | |
@echo "... src/Main.o" | |
@echo "... src/Main.i" | |
@echo "... src/Main.s" | |
.PHONY : help | |
#============================================================================= | |
# Special targets to cleanup operation of make. | |
# Special rule to run CMake to check the build system integrity. | |
# No rule that depends on this can have commands that come from listfiles | |
# because they might be regenerated. | |
cmake_check_build_system: | |
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 | |
.PHONY : cmake_check_build_system |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment