The pv_memory_profiling(type int) and environment variable MALLOC_CONF are used by GaussDB(DWS) to control the enabling and disabling of the memory allocation call stack recording module and the output of the memory call stack. The following figure illustrates the process.
The environment variable MALLOC_CONF is used to enable the monitoring module. It is in the ${BIGDATA_HOME}/mppdb/.mppdbgs_profile file and is enabled by default. Note the following points:
Commands for enabling and disabling MALLOC_CONF:
export MALLOC_CONF=prof:true
export MALLOC_CONF=prof:false
Parameter description: Controls the backtrace recording and output of memory allocation functions such as malloc in the kernel.
Value range: a positive integer from 0 to 3.
pv_memory_profiling Value |
Description |
---|---|
0 |
Disables the memory trace function and does not record information of call stacks such as malloc. |
1 |
Enables the memory trace function to record information of call stacks such as malloc. |
2 |
Outputs trace logs of call stacks such as malloc.
|
3 |
Outputs memory statistics.
|
Return type: Boolean
Note:
Procedure:
1 | select * from pv_memory_profiling(2); |
jeprof --text --show_bytes $GAUSSHOME/bin/gaussdb trace file 1 >prof.txt
Method 2: Export the report in PDF format.
jeprof --pdf --show_bytes $GAUSSHOME/bin/gaussdb trace file 1 > prof.pdf
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 | -- Log in as the system administrator, set environment variables, and start the database. export MALLOC_CONF=prof:true -- Disable the memory trace recording function when the database is running. select pv_memory_profiling(0); pv_memory_profiling ---------------------------- t (1 row) -- Enable the memory trace recording function when the database is running. select pv_memory_profiling(1); pv_memory_profiling ---------------------------- t (1 row) -- Output memory trace records. select pv_memory_profiling(2); pv_memory_profiling ---------------------------- t (1 row) -- Generate the trace file in text or PDF format in the directory where the GaussDB process is located. jeprof --text --show_bytes $GAUSSHOME/bin/gaussdb trace file 1 >prof.txt jeprof --pdf --show_bytes $GAUSSHOME/bin/gaussdb trace file 1 > prof.pdf -- Output memory statistics. Execute the following statement to generate the memory statistics file in the directory where the GaussDB process is located. The file can be directly read. select pv_memory_profiling(3); pv_memory_profiling ---------------------------- t (1 row) |