私が尋ねた質問に対する答えを得ました。
アプリケーションメモリアロケータ:
CおよびC++開発者は、メモリ割り当てと空きメモリを手動で管理する必要があります。デフォルトのメモリアロケータはlibcライブラリにあります。
Libc free()が実行された後、解放されたスペースはアプリケーションによる追加の割り当てに使用できるようになり、システムに戻されないことに注意してください。アプリケーションが終了したときにのみ、メモリがシステムに返されます。そのため、通常、アプリケーションのプロセスサイズは決して減少しません。ただし、長時間実行されるアプリケーションの場合、解放されたメモリは再利用できるため、アプリケーションのプロセスサイズは通常安定した状態のままです。そうでない場合は、アプリケーションがメモリリークを起こしている可能性があります。つまり、割り当てられたメモリは使用されますが、使用されなくなったときに解放されることはなく、割り当てられたメモリへのポインタはアプリケーションによって追跡されません。基本的には失われます。
The default memory allocator in libc is not good for multi-threaded applications when a concurrent malloc or free operation occurs frequently, especially for multi-threaded C++ applications. This is because creating and destroying C++ objects is part of C++ application development style. When the default libc allocator is used, the heap is protected by a single heap-lock, causing the default allocator not to be scalable for multi-threaded applications due to heavy lock contentions during malloc or free operations. It's easy to detect this problem with Solaris tools, as follows.
First, use prstat -mL -p to see if the application spends much time on locks; look at the LCK column. For example:
-bash-3.2# prstat -mL -p 14052
PID USERNAME USR SYS TRP TFL DFL LCK SLP LAT VCX ICX SCL SIG PROCESS/LWPID
14052 root 0.6 0.7 0.0 0.0 0.0 35 0.0 64 245 13 841 0 test_vector_/721
14052 root 1.0 0.0 0.0 0.0 0.0 35 0.0 64 287 5 731 0 test_vector_/941
14052 root 1.0 0.0 0.0 0.0 0.0 35 0.0 64 298 3 680 0 test_vector_/181
14052 root 1.0 0.1 0.0 0.0 0.0 35 0.0 64 298 3 1K 0 test_vector_/549
....
It shows that the application spend about 35 percent of its time waiting for locks.
Then, using the plockstat(1M) tool, find what locks the application is waiting for. For example, trace the application for 5 seconds with process ID 14052, and then filter the output with the c++filt utility for demangling C++ symbol names. (The c++filt utility is provided with the Sun Studio software.) Filtering through c++filt is not needed if the application is not a C++ application.
-bash-3.2# plockstat -e 5 -p 14052 | c++filt
Mutex block
Count nsec Lock Caller
-------------------------------------------------------------------------------
9678 166540561 libc.so.1‘libc_malloc_lock libCrun.so.1‘void operator
delete(void*)+0x26
5530 197179848 libc.so.1‘libc_malloc_lock libCrun.so.1‘void*operator
new(unsigned)+0x38
......
From the preceding, you can see that the heap-lock libc_malloc_lock is heavily contended for and is a likely cause for the scaling issue. The solution for this scaling problem of the libc allocator is to use an improved memory allocator like the libumem library.
Also visit: http://developers.sun.com/solaris/articles/solaris_memory.html
Thanks for all who tried to answer my question,
Santhosh.