Memory Usage
Command Function
Collects performance data about memory allocation and release, and checks whether any allocated memory space has not been released.
Syntax
1 | devkit doctor memalloc [-h] [-l {0,1,2,3}] [--package] [-o <file>] [-d <sec>] [-i <sec>] [-t n] [-z <byte>] [-Z <byte>] [-p PID] [workload workload ...] |
- The tool can collect data of a specified application. Replace workload workload ... in the command with the application path and application parameter.
- This command is unavailable on SUSE Linux.
- This function is implemented based on the eBPF capability. The root user is used for data collection. For details about how to check whether the environment meets the requirements, see Checking the eBPF Environment.
Parameter Description
Parameter |
Option |
Description |
|---|---|---|
-h/--help |
- |
Obtains help information. |
-d/--duration |
- |
Collection duration, in seconds. By default collection does not stop until the application stops running. You can press Ctrl+C to stop the collection and start analysis. |
-i/--interval |
- |
Collection interval, in seconds. The default value is 1 second. The value ranges from 1 to 60 seconds and cannot exceed the collection duration. |
-l/--log-level |
0/1/2/3 |
Log level, which defaults to 2.
|
-o/--output |
- |
Report file name. Reports are generated in the current directory by default. |
--package |
- |
Indicates whether to import data to the database and generate compressed packages in the specified output path. |
-t/--top |
- |
Top N stacks with the highest memory usage, which defaults to 5. The value ranges from 5 to 15. The report output is sorted by stack size. |
-z/--min-size |
- |
Minimum memory usage collected each time, in bytes. The value must be greater than or equal to 1. |
-Z/--max-size |
- |
Maximum memory usage collected each time, in bytes. The value must be greater than or equal to 2. |
-p/--pid |
- |
ID of the process to be collected, which defaults to -1, indicating that the kernel-mode memory usage is collected. |
Example
1 | devkit doctor memalloc -d 1 -i 1 -t 5 |
If you want to collect data of an application, add the path of the application executable file to the end of the command.
Command output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | Attaching to kernel allocators, Ctrl+C to quit. Memory Allocate Summary Report-1 Time:2024/11/17 15:40:43 ================================================================================ Top 5 stacks with outstanding allocations: Top 1 stack ───────────────────────────────────────────────────────────────── stack_name __alloc_pages_nodemask+0x208 [kernel] stack_id 3305 alloc_size 3407872B alloc_count 52 alloc_distribution 64KB-128KB 52 alloc_pid 1181280 stack_info: 0xffff0000082aed48 __alloc_pages_nodemask+0x208 [kernel] 0xffff0000082aed48 __alloc_pages_nodemask+0x208 [kernel] 0xffff000008325ad0 alloc_pages_vma+0x90 [kernel] 0xffff0000082e9978 wp_page_copy+0xa0 [kernel] 0xffff0000082ed468 do_wp_page+0xd8 [kernel] 0xffff0000082f0c80 __handle_mm_fault+0x538 [kernel] 0xffff0000082f1048 handle_mm_fault+0xd8 [kernel] 0xffff000008ab9fb0 do_page_fault+0x210 [kernel] 0xffff0000080812d0 do_mem_abort+0x68 [kernel] 0xffff000008083b64 el0_da+0x24 [kernel] ... ... ... ... Top 5 stack ───────────────────────────────────────────────────────────────── stack_name __alloc_pages_nodemask+0x208 [kernel] stack_id 8792 alloc_size 196608B alloc_count 3 alloc_distribution 64KB-128KB 3 alloc_pid 1181280 stack_info: 0xffff0000082aed48 __alloc_pages_nodemask+0x208 [kernel] 0xffff0000082aed48 __alloc_pages_nodemask+0x208 [kernel] 0xffff000008323eb8 alloc_pages_current+0x88 [kernel] 0xffff0000082a9560 __get_free_pages+0x28 [kernel] 0xffff0000082fb890 tlb_remove_table+0xa8 [kernel] 0xffff0000082ea818 free_pgd_range+0x168 [kernel] 0xffff0000082eab3c free_pgtables+0x12c [kernel] 0xffff0000082f8278 exit_mmap+0xe8 [kernel] 0xffff0000080f60bc mmput+0x74 [kernel] 0xffff0000080ff530 do_exit+0x300 [kernel] 0xffff0000080ff8cc do_group_exit+0x3c [kernel] 0xffff0000080ff98c __arm64_sys_exit_group+0x24 [kernel] 0xffff0000080999f0 el0_svc_common+0x78 [kernel] 0xffff000008099b28 el0_svc_handler+0x38 [kernel] 0xffff000008084188 el0_svc+0x8 [kernel] |
Use the --package parameter to generate a TAR package. You can import the TAR package to the WebUI to view the graphical information. For details about how to import a TAR package, see Task Management.