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 works based on eBPF and requires the root user.
Parameter Description
Parameter |
Option |
Description |
|---|---|---|
-h/--help |
- |
Obtains help information. This parameter is optional. |
-l/--log-level |
0/1/2/3 |
Log level, which defaults to 2. This parameter is optional.
NOTE:
The default level is 2 (WARNING).
|
--package |
- |
Indicates whether to import data to the database and generate compressed packages in the specified output path. This parameter is optional. |
-o/--output |
- |
Report package name and output path. If you enter a name only, the report package is generated in the current directory by default. This option must be used together with --package. |
-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. This parameter is optional. |
-i/--interval |
- |
Collection interval, in seconds. This parameter is optional. The default value is 1 second. The value ranges from 1 to 60 seconds and cannot exceed the collection duration. |
-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. This parameter is optional. |
-z/--min-size |
- |
Minimum memory usage collected each time, in bytes. The value must be greater than or equal to 1. This parameter is optional. |
-Z/--max-size |
- |
Maximum memory usage collected each time, in bytes. The value must be greater than or equal to 2. This parameter is optional. |
-p/--pid |
- |
ID of the process to be collected, which defaults to -1, indicating that the kernel-mode memory usage is collected. This parameter is optional. |
Example
1 | devkit doctor memalloc -d 1 -i 1 -t 5 --package |
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 56 57 58 59 | Attaching to kernel allocators, Ctrl+C to quit. Memory Allocate Summary Report-1 Time:2025/06/20 16:06:12 ================================================================================ 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] The report /home/memalloc-20250620-160605.tar is generated successfully. To view summary report. you can run: devkit report -i /home/memalloc-20250620-160605.tar To view detail report. you can import the report to the WebUI or IDE to view details. |
You can use the --package parameter to create a TAR package, which can then be imported into the WebUI to view the graphical information.