1Demonstrations of uobjnew.
2
3
4uobjnew summarizes new object allocation events and prints out statistics on
5which object type has been allocated frequently, and how many bytes of that
6type have been allocated. This helps diagnose common allocation paths, which
7can in turn cause heavy garbage collection.
8
9For example, trace Ruby object allocations when running some simple commands
10in irb (the Ruby REPL):
11
12# ./uobjnew -l ruby 27245
13Tracing allocations in process 27245 (language: ruby)... Ctrl-C to quit.
14
15TYPE                           # ALLOCS      # BYTES
16NameError                             1            0
17RubyToken::TkSPACE                    1            0
18RubyToken::TkSTRING                   1            0
19String                                7            0
20RubyToken::TkNL                       2            0
21RubyToken::TkIDENTIFIER               2            0
22array                                55          129
23string                              344         1348
24^C
25
26
27Plain C/C++ allocations (through "malloc") are also supported. We can't report
28the type being allocated, but we can report the object sizes at least. Also,
29print only the top 10 rows by number of bytes allocated:
30
31# ./uobjnew -S 10 -l c 27245
32Tracing allocations in process 27245 (language: c)... Ctrl-C to quit.
33
34TYPE                           # ALLOCS      # BYTES
35block size 64                        22         1408
36block size 992                        2         1984
37block size 32                        68         2176
38block size 48                        48         2304
39block size 944                        4         3776
40block size 1104                       4         4416
41block size 160                       32         5120
42block size 535                       15         8025
43block size 128                      112        14336
44block size 80                       569        45520
45^C
46
47
48USAGE message:
49
50# ./uobjnew -h
51usage: uobjnew.py [-h] [-l {c,java,ruby,tcl}] [-C TOP_COUNT] [-S TOP_SIZE] [-v]
52                  pid [interval]
53
54Summarize object allocations in high-level languages.
55
56positional arguments:
57  pid                   process id to attach to
58  interval              print every specified number of seconds
59
60optional arguments:
61  -h, --help            show this help message and exit
62  -l {c,java,ruby,tcl}, --language {c,java,ruby,tcl}
63                        language to trace
64  -C TOP_COUNT, --top-count TOP_COUNT
65                        number of most frequently allocated types to print
66  -S TOP_SIZE, --top-size TOP_SIZE
67                        number of largest types by allocated bytes to print
68  -v, --verbose         verbose mode: print the BPF program (for debugging
69                        purposes)
70
71examples:
72    ./uobjnew -l java 145         # summarize Java allocations in process 145
73    ./uobjnew -l c 2020 1         # grab malloc() sizes and print every second
74    ./uobjnew -l ruby 6712 -C 10  # top 10 Ruby types by number of allocations
75    ./uobjnew -l ruby 6712 -S 10  # top 10 Ruby types by total size
76