Bytehound: a more powerful Linux memory analysis tool

Time:2021-12-9

[introduction]: a more powerful Linux memory analysis tool.

brief introduction

Bytehound is a memory analysis tool for Linux. It can display memory change curve, occupancy details, complete stack records and other information, which is helpful to solve problems such as memory leakage. The detailed functions are as follows:

  • It can be used to analyze memory leaks, accurately view memory consumption, identify temporarily allocated memory and detect memory fragments
  • Collect the information of each application and memory release operation, and track the complete stack information
  • It can dynamically eliminate the temporarily allocated memory and analyze it for a long time
  • The use of a custom stack information presentation implementation makes it more efficient than other similar tools and may be several orders of magnitude faster in some cases
  • The collected data can be exported to various formats: the data can be exported to JSON, heaptrack (which can be analyzed by using heaptrack GUI) and flame diagram
  • Web based GUI for analysis
  • Analysis data can be dynamically streamed to another machine instead of being stored locally, which is very useful for analysis on memory constrained systems
  • Supports AMD64, arm, aarch64 and MIPS64 architectures (MIPS64 requires a kernel patch perf_event_open)
  • Support analysis of applications using jemalloc as allocator (only applicable to jemallocator based on AMD64 Architecture)
  • Support rhai based embedded DSL, allowing programming and automatic data analysis

Bytehound: a more powerful Linux memory analysis tool

Bytehound: a more powerful Linux memory analysis tool

Bytehound: a more powerful Linux memory analysis tool

Bytehound: a more powerful Linux memory analysis tool

The project address is:

https://github.com/koute/byte…

install

  1. GCC, rust and yarn are installed to build the GUI
  2. structure
$ cargo build --release -p bytehound-preload
$ cargo build --release -p bytehound-cli
  1. Get binaries from target / release / libbytehound.so or target / release / bytehound

usage

Basic Usage

$ export MEMORY_PROFILER_LOG=warn
$ LD_PRELOAD=./libbytehound.so ./your_application
$ ./bytehound server memory-profiling_*.dat

Then open the browser to accesshttp://localhost:8080

Open debug log

For performance reasons, the analyzer disables most debug logs at compile time by default. If you want to enable debug logs, you need to use the debug logs function to recompile and build:

$ cd preload
$ cargo build --release --features debug-logs

environment variable

Bytehound analyzer controls its behavior through many environment variables. The following are some commonly used environment variables.

MEMORY_PROFILER_OUTPUT

Default: memory profiling #% e_% t_% p. DAT, indicating the path of the file to which the data will be written, supports placeholders, which will be replaced at runtime with the following:% p – > PID of the process% T – > seconds since the UNIX era% e – > name of the executable file% n – > automatic increment counter (0, 1,…, 9, 10, etc.)

MEMORY_PROFILER_LOG

The log level to use; Possible values: trace, debug, info, warn, error

MEMORY_PROFILER_LOGFILE

The path of the file to which the log will be written; If not set, the log will be sent to stderr and support similar to memory_ PROFILER_ Placeholder for output (except% n).

MEMORY_PROFILER_CULL_TEMPORARY_ALLOCATIONS

Default value: 0. When set to 1, temporary assignments are eliminated and omitted from the output. If you only care about memory leaks or want to conduct long-term analysis in a few days, you can set it to 1.

MEMORY_PROFILER_PRECISE_TIMESTAMPS

Default value: 0, which determines when to collect time stamps for each event or only for event blocks. When enabled, the timestamp will be more accurate, but will increase CPU utilization.

Open source outpostShare popular, interesting and practical open source projects on a daily basis. Participate in maintaining the open source technology resource library of 100000 + star, including python, Java, C / C + +, go, JS, CSS, node.js, PHP,. Net, etc.

Recommended Today

Information entropy and conditional entropy

introduction Today, I suddenly saw the term “information entropy” when I was browsing the paper. I remembered it with a snap. Soon!! Isn’t this the first professional term I talked about in the first introduction to information resource management in my freshman year? I’m familiar with information entropy. I’ll come soon. Information entropy is negative […]