Write code--debug--fix bug
Change to change there may still be some problems that are not found, when the project volume is more prone to occur, such as memory leaks such problems, serious impact on system performance.
There are some tools on the Internet that detect if a memory leak exists in a C program, such as Valgrind.
Scripts are written to detect whether the application running in the server has a memory leak problem.
Ideas are as follows:
file 1:processlist, which is used to save the name of the application requiring memory leak detection, is managed by the file 2:testmanage, or by using the./testmanage-a app name to add or./testmanage-d app Name To remove.
3:memoryleaktest . file, main program. First, empty the file 4:rsslist (used to save the memory test results of the process ) and file 5: LeakMemory.log (to hold the name of the application that has a memory leak).
in the beginning loop 1, loop 6 times, each cycle through the file 1 all the application name-process number-status file gets the memory size, save with file 4, each cycle interval 1800 seconds, so total 2.5 hours.
at the end of the third step, according to the 6 memory size of all applications saved in file 4, the next two comparisons, if the following is greater than the previous 10%,flag variable value +1, a total of 5 times, if the flag is greater than or equal to 4, the application has a memory leak.
Shell notes:
Usage of sed:
Add the following line in the matching string: Sed-i/$str/a\ "$str _new" $filename
Add a line on the matching string: Sed-i "/$str/i\\ $str _new" $filename $str _new before one \ is escaped
Two variables with underline connection: ${STR1}_${STR2}
02.
" $str 1 " - F $str 2 $p " NP "
Match the first m row of STR1, after the column containing the str2 p, take the nth row.
Detecting memory leaks in your application (shell)