Rate This Document
Findability
Accuracy
Completeness
Readability

Memory Usage

Command Function

Collects performance data about memory allocation and release, and checks whether any allocated memory space has not been released.

Syntax

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 workload...] can be used to 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

Table 1 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.
  • 0: DEBUG
  • 1: INFO
  • 2: WARNING
  • 3: ERROR

-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 whose information is to be collected, which defaults to -1, indicating that the kernel-mode memory usage is collected.

Example

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:

Attaching to kernel allocators, Ctrl+C to quit.
Memory Allocate Summary Report-1                        Time:2024/07/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
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 2 stack
─────────────────────────────────────────────────────────────────
stack_name                kmem_cache_alloc+0x188 [kernel]
stack_id                  15249
alloc_size                292352B
alloc_count               1142
alloc_distribution        256B-512B 1142
stack_info:
0xffff000008333188        kmem_cache_alloc+0x188 [kernel]
0xffff000008333188        kmem_cache_alloc+0x188 [kernel]
0xffff00000836fd94        __alloc_file+0x34 [kernel]
0xffff0000083701a0        alloc_empty_file+0x68 [kernel]
0xffff0000083819cc        path_openat+0x4c [kernel]
0xffff0000083830e0        do_filp_open+0x88 [kernel]
0xffff00000836aa58        do_sys_open+0x1a8 [kernel]
0xffff00000836ab4c        __arm64_sys_openat+0x2c [kernel]
0xffff0000080999f0        el0_svc_common+0x78 [kernel]
0xffff000008099b28        el0_svc_handler+0x38 [kernel]
0xffff000008084188        el0_svc+0x8 [kernel]
Top 3 stack
─────────────────────────────────────────────────────────────────
stack_name                __alloc_pages_nodemask+0x208 [kernel]
stack_id                  10583
alloc_size                262144B
alloc_count               4
alloc_distribution        64KB-128KB 4
stack_info:
0xffff0000082aed48        __alloc_pages_nodemask+0x208 [kernel]
0xffff0000082aed48        __alloc_pages_nodemask+0x208 [kernel]
0xffff000008323eb8        alloc_pages_current+0x88 [kernel]
0xffff00000833127c        allocate_slab+0x43c [kernel]
0xffff0000083313fc        new_slab+0x64 [kernel]
0xffff000008332e04        ___slab_alloc+0x40c [kernel]
0xffff000008332fe4        __slab_alloc+0x5c [kernel]
0xffff0000083331dc        kmem_cache_alloc+0x1dc [kernel]
0xffff00000836fd94        __alloc_file+0x34 [kernel]
0xffff0000083701a0        alloc_empty_file+0x68 [kernel]
0xffff0000083819cc        path_openat+0x4c [kernel]
0xffff0000083830e0        do_filp_open+0x88 [kernel]
0xffff00000836aa58        do_sys_open+0x1a8 [kernel]
0xffff00000836ab4c        __arm64_sys_openat+0x2c [kernel]
0xffff0000080999f0        el0_svc_common+0x78 [kernel]
0xffff000008099b28        el0_svc_handler+0x38 [kernel]
0xffff000008084188        el0_svc+0x8 [kernel]
Top 4 stack
─────────────────────────────────────────────────────────────────
stack_name                __alloc_pages_nodemask+0x208 [kernel]
stack_id                  10847
alloc_size                196608B
alloc_count               3
alloc_distribution        64KB-128KB 3
stack_info:
0xffff0000082aed48        __alloc_pages_nodemask+0x208 [kernel]
0xffff0000082aed48        __alloc_pages_nodemask+0x208 [kernel]
0xffff000008323eb8        alloc_pages_current+0x88 [kernel]
0xffff0000082e960c        __do_fault+0xf4 [kernel]
0xffff0000082eedb8        do_cow_fault+0x118 [kernel]
0xffff0000082f0b18        __handle_mm_fault+0x3d0 [kernel]
0xffff0000082f1048        handle_mm_fault+0xd8 [kernel]
0xffff000008ab9fb0        do_page_fault+0x210 [kernel]
0xffff000008aba340        do_translation_fault+0xa8 [kernel]
0xffff0000080812d0        do_mem_abort+0x68 [kernel]
0xffff000008083210        el1_da+0x20 [kernel]
0xffff000008a94b80        __arch_clear_user+0x20 [kernel]
0xffff0000083fe884        load_elf_binary+0x874 [kernel]
0xffff000008377bec        search_binary_handler+0xcc [kernel]
0xffff0000083787b8        __do_execve_file.isra.13+0x608 [kernel]
0xffff000008378a10        do_execve+0x48 [kernel]
0xffff000008378c80        __arm64_sys_execve+0x30 [kernel]
0xffff0000080999f0        el0_svc_common+0x78 [kernel]
0xffff000008099b28        el0_svc_handler+0x38 [kernel]
0xffff000008084188        el0_svc+0x8 [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
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.