.
그러나 USDT를 사용하여 사용자 공간 프로세스를 추적 할 수 있습니다. The bcc tools에는 uobjnew
이라는 예가 들어 있습니다. 주어진 프로세스에서 객체 할당을 추적합니다 :
$ ./uobjnew -h
usage: uobjnew.py [-h] [-l {java,ruby,c}] [-C TOP_COUNT] [-S TOP_SIZE] [-v]
pid [interval]
Summarize object allocations in high-level languages.
positional arguments:
pid process id to attach to
interval print every specified number of seconds
optional arguments:
-h, --help show this help message and exit
-l {java,ruby,c}, --language {java,ruby,c}
language to trace
-C TOP_COUNT, --top-count TOP_COUNT
number of most frequently allocated types to print
-S TOP_SIZE, --top-size TOP_SIZE
number of largest types by allocated bytes to print
-v, --verbose verbose mode: print the BPF program (for debugging
purposes)
examples:
./uobjnew -l java 145 # summarize Java allocations in process 145
./uobjnew -l c 2020 1 # grab malloc() sizes and print every second
./uobjnew -l ruby 6712 -C 10 # top 10 Ruby types by number of allocations
./uobjnew -l ruby 6712 -S 10 # top 10 Ruby types by total size
'malloc'은 시스템 호출이 아닙니다. GNU Glibc 라이브러리에서는'mmap'과'sbrk' 시스템 콜을 사용하여 구현됩니다. 아마도 사용자 응용 프로그램에서'valgrind'를 사용하기를 원할지도 모릅니다. 커널 자체는'kmalloc'과 관련된 커널 기능을 사용하여 동적 메모리 (커널 내부, 응용 프로그램 제외)를 할당하고 있습니다. –
그리고'pmap'을 사용할 수도 있고, pid 1234의 프로세스는'/ proc/1234/status'와'/ proc/1234/maps' 등을 들여다 봅니다. –