Lines Matching refs:memory

4 …sms, such as memory leak check, heap memory statistics, memory corruption check, and backtrace, to…
7memory node integrity is checked when memory is requested and released by an application. When the…
14 The memory debugging module maintains 128 (that is the maximum number of threads supported in the s…
16 When memory is requested, key information is saved to the memory node control block, which is inser…
18 When memory is released, the system matches the memory node control block based on the memory addre…
20 **Figure 1** Heap memory node linked list
22 ![](figures/heap-memory-node-linked-list.png "heap-memory-node-linked-list")
24memory is allocated, the returned address is saved in a link register (LR). During the process run…
26 **Figure 2** Heap memory node information
28 ![](figures/heap-memory-node-information.png "heap-memory-node-information")
30 … ID; **ptr** indicates the address of the memory requested; **size** indicates the size of the req…
32memory is released, the input parameter pointer in the **free** API is used to match the **ptr** f…
34memory debugging information of each process through the serial port or file, and use the addr2lin…
36 **Figure 3** Process of locating the code line for a memory leak
38 …es/process-of-locating-the-code-lines-for-a-memory-leak.png "process-of-locating-the-code-lines-fo…
43memory requested by each thread to provide data support for optimizing memory usage of user progra…
48 - Requested memory less than or equal to 0x1c000 bytes
50 …When the requested memory is less than or equal to 0x1c000 bytes, **malloc** uses the heap allocat…
52memory, information such as the check value is added to the heap memory node. If the check value i…
58memory is released by **free**, the memory block is not released immediately. Instead, the magic n…
60 **Figure 5** Process of releasing memory
62 ![](figures/process-of-releasing-memory.png "process-of-releasing-memory")
66 - Requested memory greater than 0x1c000 bytes
68 …When the requested memory is greater than 0x1c000 bytes, **malloc** uses **mmap** to allocate memo…
70memory block, one more page is allocated at the start and end of the memory region. The current **…
72 **Figure 6** Layout of the memory allocated by using the **mmap** mechanism of **malloc**
74 …![](figures/layout-of-the-memory-allocated-by-using-the-mmap-mechanism-of-malloc.png "layout-of-th…
84 | mem_check_init | Initializes the memory check module.|
85 | watch_mem | Obtains the thread-level heap memory usage.|
86 | check_leak | Checks for heap memory leaks.|
87 | check_heap_integrity | Checks the heap memory integrity.|
104 …library of the debug version has integrated the APIs for memory debugging. You can enable memory d…
107 You can perform heap memory debugging by using either of the following:
110 - API: By calling APIs, you can accurately check the heap memory information of a specific code log…
112 … need to modify user code. However, you cannot accurately check the heap memory information of a s…
116memory debugging is enabled, a heap memory leak check and a heap memory integrity check will be pe…
126 …e sample code explicitly calls the related APIs of the memory debugging module to check the memory.
133 #include <debug.h> // Header file that includes the declaration of the memory debugging APIs
145 …Output the memory debugging information through the serial port. This function must be called befo…
146 …// mem_check_init("/storage/mem_debug.txt"); // Output the memory debugging information to the /st…
150 watch_mem(); // Obtain the thread-level memory statistics in the current code.
152 check_heap_integrity(); // Check the integrity of the heap memory nodes.
153 …check_leak(); // Check whether a heap memory leak occurs in the current code. (Generally, the chec…
188 ==PID:4== Heap memory statistics(bytes): // Heap memory statistics
193 …[TID: 18, Used: 0x320] // The heap memory is occupied by thread No. 18. The current process has on…
197 Check heap integrity ok! // Heap memory integrity check
199 ==PID:4== Detected memory leak(s): // Memory leak information and call stack
215 ==PID:4== Detected memory leak(s):
237 …code line number. In the following command, **mem_debug.txt** stores the memory debugging informat…
252 ==PID:4== Heap memory statistics(bytes):
263 ==PID:4== Detected memory leak(s):
283 … check the memory used by user-mode processes, you can run CLI commands to collect memory statisti…
286 --mwatch: initializes memory debugging, registers signals, and outputs memory debugging information…
287memory debugging, registers signals, and saves the memory debugging information to the f_path file…
294 kill -35 <pid> # Check the thread-level heap memory usage.
295 kill -36 <pid> # Check for heap memory leaks.
296 kill -37 <pid> # Check whether the head node of the heap memory is complete.
302 The sample code constructs a memory problem and uses the command line to perform memory debugging.
339 OHOS # kill -35 4 // Check heap memory statistics.
341 ==PID:4== Heap memory statistics(bytes):
349 OHOS # kill -36 4 // Check for heap memory leaks.
351 ==PID:4== Detected memory leak(s):
367 OHOS # kill -37 4 // Check the integrity of the head node of the heap memory.
375 … the script to parse the information to obtain the number of the line where the memory leak occurs.
383 ==PID:4== Detected memory leak(s):
403 1. Run the user program and specify the path of the file that stores the memory debugging informati…
409 2. Run the **kill -35 <*pid*>** command to collect statistics on the memory information. The inform…
417 ==PID:4== Heap memory statistics(bytes):
426 3. Run the **kill -36 <*pid*>** command to check memory integrity. The information is exported to a…
434 ==PID:4== Heap memory statistics(bytes):
442 ==PID:4== Detected memory leak(s):
459 …*pid*>** command to kill the current process. After the process exits, a memory integrity check is…
469 ==PID:4== Heap memory statistics(bytes):
477 ==PID:4== Detected memory leak(s):
493 ==PID:4== Detected memory leak(s):
517 - Requested memory less than or equal to 0x1c000 bytes:
519 …Read operation: If the magic number (0xFEFEFEFE) is read from the memory block released, UAF occur…
523memory will not be released to the heap memory pool immediately. Instead, the heap memory is place…
525 Write operation: The memory debugging module cannot detect UAF errors from write operations.
528 - Requested memory block greater than 0x1c000 bytes:
530memory greater than 0x1c000 bytes must be requested by calling the **mmap** API via **malloc**. If…
535 Double free errors occur when **free()** is called more than once with the same memory address as a…
540 - Requested memory block less than or equal to 0x1c000 bytes:
542memory node is corrupted, the user program exits unexpectedly, and the call stack that requests th…
556 - Requested memory block greater than 0x1c000 bytes:
558memory block (greater than 0x1c000 bytes) is requested by calling the **mmap** API via **malloc**,…