C++ exe程序内存占用分析

38 篇文章 0 订阅
2 篇文章 0 订阅
编译 
$ git clone https://github.com/google/bloaty
$ cd bloaty
$ cmake -B build -G Ninja -S .
$ cmake --build build
$ cmake --build build --target install
命令
bloaty.exe	--list-sources

rmembers       the .o files in a .a file
compileunits    source file for the .o file (translation unit). requires debug info.
inputfiles      the filename specified on the Bloaty command-line
inlines         source line/file where inlined code came from.  requires debug info.
sections        object file section
segments        load commands in the binary
symbols         symbols from symbol table (configure demangling with --demangle)
rawsymbols      unmangled symbols
fullsymbols     full demangled symbols
shortsymbols    short demangled symbols

 


bloaty.exe	--help

USAGE: bloaty [OPTION]... FILE... [-- BASE_FILE...]

Options:

  --csv              Output in CSV format instead of human-readable.
  --tsv              Output in TSV format instead of human-readable.
  -c FILE            Load configuration from <file>.
  -d SOURCE,SOURCE   Comma-separated list of sources to scan.
  --debug-file=FILE  Use this file for debug symbols and/or symbol table.
  -C MODE            How to demangle symbols.  Possible values are:
  --demangle=MODE      --demangle=none   no demangling, print raw symbols
                       --demangle=short  demangle, but omit arg/return types
                       --demangle=full   print full demangled type
                     The default is --demangle=short.
  --disassemble=FUNCTION
                     Disassemble this function (EXPERIMENTAL)
  --domain=DOMAIN    Which domains to show.  Possible values are:
                       --domain=vm
                       --domain=file
                       --domain=both (the default)
  -n NUM             How many rows to show per level before collapsing
                     other keys into '[Other]'.  Set to '0' for unlimited.
                     Defaults to 20.
  -s SORTBY          Whether to sort by VM or File size.  Possible values
                     are:
                       -s vm
                       -s file
                       -s both (the default: sorts by max(vm, file)).
  -w                 Wide output; don't truncate long labels.
  --help             Display this message and exit.
  --list-sources     Show a list of available sources and exit.
  --source-filter=PATTERN
                     Only show keys with names matching this pattern.

Options for debugging Bloaty:

  --debug-vmaddr=ADDR
  --debug-fileoff=OFF
                     Print extended debugging information for the given
                     VM address and/or file offset.
  -v                 Verbose output.  Dumps warnings encountered during
                     processing and full VM/file maps at the end.
                     Add more v's (-vv, -vvv) for even more.
 测试
#include <iostream>

const char* data = "而此时是ii四十九而此时是ii四十九而此时是ii四十九而此时是ii四十九而此时是ii四十九而此时是ii四十九而此时是ii四十九而此时是ii四十九而此时是ii四十九而此时是ii四十九";

int main() {
	printf("test main\n");
}
g++ -g main.cpp -o  my_program.exe
bloaty   my_program.exe

 

配置
bloaty -c bloaty_package.bloaty my_program.exe

 bloaty_package.bloaty

custom_data_source: {
  name: "bloaty_package"
  base_data_source: "compileunits"

  rewrite: {
    pattern: "^(\\.\\./)?src"
    replacement: "src"
  }
  rewrite: {
    pattern: "^(\\.\\./)?(third_party/\\w+)"
    replacement: "\\2"
  }
}
参考

GitHub - google/bloaty: Bloaty: a size profiler for binaries

C/C++ Native 包大小测量_bloaty-CSDN博客


创作不易,小小的支持一下吧!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

码力码力我爱你

创作不易,小小的支持一下吧!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值