RE: Memory Free up Failing on Solaris 8 - Off-topic
Anjo response is correct. Try running truss against your executable. You will see that brk is called for allocating memory. The way I understand it is, brk/sbrk is the system call which allocates/deallocates memory and malloc is the user mode library which internally calls brk/sbrk. I don't think free actually releases the memory back to the OS, but may reuse the memory for another request. Run the attached program and check the output. After you free the memory, the next malloc allocates the same memory which has been freed. Output of truss snipped on your program = fstat(3, 0xFFBEEFAC)= 0 mmap(0x, 8192, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xFF31 mmap(0x, 16384, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xFF30 close(3)= 0 munmap(0xFF31, 8192)= 0 ioctl(1, TCGETA, 0xFFBEEBA4)= 0 allocating [20480] bytes write(1, a l l o c a t i n g [.., 25) = 25 brk(0x00020ED0) = 0 brk(0x00026ED0) = 0 ioctl(0, TCGETA, 0xFFBEF7CC)= 0 read(0, \n, 1024) = 1 Freeing [1] write(1, F r e e i n g [ 1 ]\n, 12)= 12 read(0, 0xFF2BF634, 1024) (sleeping...) read(0, \n, 1024) = 1 allocating [30720] bytes write(1, a l l o c a t i n g [.., 25) = 25 brk(0x00026ED0) = 0 brk(0x00028ED0) = 0 read(0, 0xFF2BF634, 1024) (sleeping...) read(0, \n, 1024) = 1 Freeing [2] write(1, F r e e i n g [ 2 ]\n, 12)= 12 read(0, 0xFF2BF634, 1024) (sleeping...) read(0, \n, 1024) = 1 allocating [40960] bytes write(1, a l l o c a t i n g [.., 25) = 25 brk(0x00028ED0) = 0 brk(0x0002CED0) = 0 read(0, 0xFF2BF634, 1024) (sleeping...) read(0, \n, 1024) = 1 Freeing [3] write(1, F r e e i n g [ 3 ]\n, 12)= 12 read(0, 0xFF2BF634, 1024) (sleeping...) #include stdio.h #include malloc.h #include string.h main() { char *loc1; char *loc2; printf(Allocating [%d] bytes\n, 10*1024); loc1 = (char *) malloc(10*1024); printf(Address : %x\n,loc1); printf(Allocating [%d] bytes\n, 10*1024); loc2 = (char *) malloc(10*1024); printf(Address : %x\n,loc2); free(loc1); free(loc2); printf(Allocating [%d] bytes\n, 10*1024); loc1 = (char *) malloc(10*1024); printf(Address : %x\n,loc1); printf(Allocating [%d] bytes\n, 10*1024); loc2 = (char *) malloc(10*1024); printf(Address : %x\n,loc2); free(loc1); free(loc2); printf(Allocating [%d] bytes\n, 10*1024); loc1 = (char *) malloc(10*1024); printf(Address : %x\n,loc2); free(loc1); } Regards, Denny Quoting VIVEK_SHARMA [EMAIL PROTECTED]: Hi brk, sbrk functions are used for DATA segments and we have problem with HEAP. Malloc allocates space onto heap and not in DATA segment. Seemingly the man page imply that it should not be used in conjunction with malloc, calloc , that we are using. Pasting from man pages :- USAGE The behavior of brk() and sbrk() is unspecified if an appli- cation also uses any other memory functions (such as malloc(3C), mmap(2), free(3C)). Qs. Is any alternative function which can be used OR am i missing something ? Thanks -Original Message- Sent: Monday, February 03, 2003 1:19 PM To: Multiple recipients of list ORACLE-L hmm, free() doesn't do sbrk() with a negative to reduce the process space. So yes the space stays allocated. Anjo. - Original Message - To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] Sent: Monday, February 03, 2003 7:58 AM Hi SITUATION - On a production APP Server having about 4000 Concurrent application processes , the memory allocated does NOT seem to be getting freed even though the application program is issuing the respective call to Free the memory . Qs Any /etc/system parameters , OS patches which should help ? Qs Is our approach of using the pmap command Correct ? else what Command to find the Private memory taken up by a process would be advisable ? Qs How to find the Total Amount of Swap Consumed ? [ We probably do NOT know how to interpret the vmstat output Correctly , top/swap -s commands show an output Differing greatly from df -k output for /tmp filesystem ] Qs Any Body has encountered such as situation before ? Configuration - Solaris 2.8 Patch - Generic 108528-16 patch Machine SF15K CPUs = 36 RAM = 96 GB We created a Small Sample C program which allocates FREEs memory but found that even after FREEing , the memory does NOT show as Freed in the pmap
Re: Memory Free up Failing on Solaris 8 - Off-topic
Thanks Denny :-) I remember writing a tool to prove this point in 1992, it was called ms (memory status), it showed all memory segments (heap, text, shared memory, shared objects, data segment etc). It worked the same as ps, but then for memory. I had enough of explaining all the time that the SZ column in ps contained the shared memory pages for the SGA also. Anjo. Denny Koovakattu wrote: Anjo response is correct. Try running truss against your executable. You will see that brk is called for allocating memory. The way I understand it is, brk/sbrk is the system call which allocates/deallocates memory and malloc is the user mode library which internally calls brk/sbrk. I don't think free actually releases the memory back to the OS, but may reuse the memory for another request. Run the attached program and check the output. After you free the memory, the next malloc allocates the same memory which has been freed. Output of truss snipped on your program = fstat(3, 0xFFBEEFAC)= 0 mmap(0x, 8192, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xFF31 mmap(0x, 16384, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xFF30 close(3)= 0 munmap(0xFF31, 8192)= 0 ioctl(1, TCGETA, 0xFFBEEBA4)= 0 allocating [20480] bytes write(1, a l l o c a t i n g [.., 25) = 25 brk(0x00020ED0) = 0 brk(0x00026ED0) = 0 ioctl(0, TCGETA, 0xFFBEF7CC)= 0 read(0, \n, 1024) = 1 Freeing [1] write(1, F r e e i n g [ 1 ]\n, 12)= 12 read(0, 0xFF2BF634, 1024) (sleeping...) read(0, \n, 1024) = 1 allocating [30720] bytes write(1, a l l o c a t i n g [.., 25) = 25 brk(0x00026ED0) = 0 brk(0x00028ED0) = 0 read(0, 0xFF2BF634, 1024) (sleeping...) read(0, \n, 1024) = 1 Freeing [2] write(1, F r e e i n g [ 2 ]\n, 12)= 12 read(0, 0xFF2BF634, 1024) (sleeping...) read(0, \n, 1024) = 1 allocating [40960] bytes write(1, a l l o c a t i n g [.., 25) = 25 brk(0x00028ED0) = 0 brk(0x0002CED0) = 0 read(0, 0xFF2BF634, 1024) (sleeping...) read(0, \n, 1024) = 1 Freeing [3] write(1, F r e e i n g [ 3 ]\n, 12)= 12 read(0, 0xFF2BF634, 1024) (sleeping...) #include stdio.h #include malloc.h #include string.h main() { char *loc1; char *loc2; printf(Allocating [%d] bytes\n, 10*1024); loc1 = (char *) malloc(10*1024); printf(Address : %x\n,loc1); printf(Allocating [%d] bytes\n, 10*1024); loc2 = (char *) malloc(10*1024); printf(Address : %x\n,loc2); free(loc1); free(loc2); printf(Allocating [%d] bytes\n, 10*1024); loc1 = (char *) malloc(10*1024); printf(Address : %x\n,loc1); printf(Allocating [%d] bytes\n, 10*1024); loc2 = (char *) malloc(10*1024); printf(Address : %x\n,loc2); free(loc1); free(loc2); printf(Allocating [%d] bytes\n, 10*1024); loc1 = (char *) malloc(10*1024); printf(Address : %x\n,loc2); free(loc1); } Regards, Denny Quoting VIVEK_SHARMA [EMAIL PROTECTED]: Hi brk, sbrk functions are used for DATA segments and we have problem with HEAP. Malloc allocates space onto heap and not in DATA segment. Seemingly the man page imply that it should not be used in conjunction with malloc, calloc , that we are using. Pasting from man pages :- USAGE The behavior of brk() and sbrk() is unspecified if an appli- cation also uses any other memory functions (such as malloc(3C), mmap(2), free(3C)). Qs. Is any alternative function which can be used OR am i missing something ? Thanks -Original Message- Sent: Monday, February 03, 2003 1:19 PM To: Multiple recipients of list ORACLE-L hmm, free() doesn't do sbrk() with a negative to reduce the process space. So yes the space stays allocated. Anjo. - Original Message - To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] Sent: Monday, February 03, 2003 7:58 AM Hi SITUATION - On a production APP Server having about 4000 Concurrent application processes , the memory allocated does NOT seem to be getting freed even though the application program is issuing the respective call to Free the memory . Qs Any /etc/system parameters , OS patches which should help ? Qs Is our approach of using the pmap command Correct ? else what Command to find the Private memory taken up by a process would be advisable ? Qs How to find the Total Amount of
Re: Memory Free up Failing on Solaris 8 - Off-topic
hmm, free() doesn't do sbrk() with a negative to reduce the process space. So yes the space stays allocated. Anjo. - Original Message - To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] Sent: Monday, February 03, 2003 7:58 AM Hi SITUATION - On a production APP Server having about 4000 Concurrent application processes , the memory allocated does NOT seem to be getting freed even though the application program is issuing the respective call to Free the memory . Qs Any /etc/system parameters , OS patches which should help ? Qs Is our approach of using the pmap command Correct ? else what Command to find the Private memory taken up by a process would be advisable ? Qs How to find the Total Amount of Swap Consumed ? [ We probably do NOT know how to interpret the vmstat output Correctly , top/swap -s commands show an output Differing greatly from df -k output for /tmp filesystem ] Qs Any Body has encountered such as situation before ? Configuration - Solaris 2.8 Patch - Generic 108528-16 patch Machine SF15K CPUs = 36 RAM = 96 GB We created a Small Sample C program which allocates FREEs memory but found that even after FREEing , the memory does NOT show as Freed in the pmap output . Is the following approach correct ? DETAILS :- @ SAMPLE C PROGRAM @ #include stdio.h main() { char *abc = NULL ; int i = 0 ; for (i = 1; i 10; i++){ printf(allocating [%d] bytes\n, 10*1024*(i+1)); abc = (char *)malloc(10*1024*(i+1)); memset(abc, '\0', 10*1024*(i+1)); getchar(); free(abc); printf(Freeing [%d]\n, i); getchar(); } exit() ; } @ RUN Output :- STEP 1 - allocating [20480] bytes pmap -x PID of Above program process Address Kbytes Resident Shared Private Permissions Mapped File 0001 8 8 8 - read/exec a.out 0002 8 8 - 8 read/write/exec a.out 00022000 24 24 - 24 read/write/exec [ heap ] FF28 688 688 688 - read/exec libc.so.1 FF33C000 32 32 - 32 read/write/exec libc.so.1 FF37 16 16 16 - read/exec libc_psr.so.1 FF39 8 8 8 - read/exec libdl.so.1 FF3A 8 8 - 8 read/write/exec [ anon ] FF3B 152 152 152 - read/exec ld.so.1 FF3E6000 8 8 - 8 read/write/exec ld.so.1 FFBEC000 16 16 - 16 read/write/exec [ stack ] -- -- -- -- total Kb 968 968 872 96 THE Private memory allocated by the [ heap ] is 24 K STEP 2 - Freeing the memory allocated in the above Step Freeing [1] pmap -x PID of Above program process Address Kbytes Resident Shared Private Permissions Mapped File 00022000 24 24 - 24 read/write/exec [ heap ] RESULT - THE Private memory allocated previously does NOT get Freed [ heap ] continues to be 24 K STEP 3 - allocating [30720] bytes pmap -x PID of Above Program process Address Kbytes Resident Shared Private Permissions Mapped File 00022000 32 32 - 32 read/write/exec [ heap ] STEP 4 - Freeing the memory allocated in the above Step Freeing [2] pmap -x PID of Above program process Address Kbytes Resident Shared Private Permissions Mapped File 00022000 32 32 - 32 read/write/exec [ heap ] RESULT - THE Private memory allocated previously in Step 3 does NOT get Freed [ heap ] continues to be 32 K Thanks -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: VIVEK_SHARMA INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Anjo Kolk INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED]
RE: Memory Free up Failing on Solaris 8 - Off-topic
Hi brk, sbrk functions are used for DATA segments and we have problem with HEAP. Malloc allocates space onto heap and not in DATA segment. Seemingly the man page imply that it should not be used in conjunction with malloc, calloc , that we are using. Pasting from man pages :- USAGE The behavior of brk() and sbrk() is unspecified if an appli- cation also uses any other memory functions (such as malloc(3C), mmap(2), free(3C)). Qs. Is any alternative function which can be used OR am i missing something ? Thanks -Original Message- Sent: Monday, February 03, 2003 1:19 PM To: Multiple recipients of list ORACLE-L hmm, free() doesn't do sbrk() with a negative to reduce the process space. So yes the space stays allocated. Anjo. - Original Message - To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] Sent: Monday, February 03, 2003 7:58 AM Hi SITUATION - On a production APP Server having about 4000 Concurrent application processes , the memory allocated does NOT seem to be getting freed even though the application program is issuing the respective call to Free the memory . Qs Any /etc/system parameters , OS patches which should help ? Qs Is our approach of using the pmap command Correct ? else what Command to find the Private memory taken up by a process would be advisable ? Qs How to find the Total Amount of Swap Consumed ? [ We probably do NOT know how to interpret the vmstat output Correctly , top/swap -s commands show an output Differing greatly from df -k output for /tmp filesystem ] Qs Any Body has encountered such as situation before ? Configuration - Solaris 2.8 Patch - Generic 108528-16 patch Machine SF15K CPUs = 36 RAM = 96 GB We created a Small Sample C program which allocates FREEs memory but found that even after FREEing , the memory does NOT show as Freed in the pmap output . Is the following approach correct ? DETAILS :- @ SAMPLE C PROGRAM @ #include stdio.h main() { char *abc = NULL ; int i = 0 ; for (i = 1; i 10; i++){ printf(allocating [%d] bytes\n, 10*1024*(i+1)); abc = (char *)malloc(10*1024*(i+1)); memset(abc, '\0', 10*1024*(i+1)); getchar(); free(abc); printf(Freeing [%d]\n, i); getchar(); } exit() ; } @ RUN Output :- STEP 1 - allocating [20480] bytes pmap -x PID of Above program process Address Kbytes Resident Shared Private Permissions Mapped File 0001 8 8 8 - read/exec a.out 0002 8 8 - 8 read/write/exec a.out 00022000 24 24 - 24 read/write/exec [ heap ] FF28 688 688 688 - read/exec libc.so.1 FF33C000 32 32 - 32 read/write/exec libc.so.1 FF37 16 16 16 - read/exec libc_psr.so.1 FF39 8 8 8 - read/exec libdl.so.1 FF3A 8 8 - 8 read/write/exec [ anon ] FF3B 152 152 152 - read/exec ld.so.1 FF3E6000 8 8 - 8 read/write/exec ld.so.1 FFBEC000 16 16 - 16 read/write/exec [ stack ] -- -- -- -- total Kb 968 968 872 96 THE Private memory allocated by the [ heap ] is 24 K STEP 2 - Freeing the memory allocated in the above Step Freeing [1] pmap -x PID of Above program process Address Kbytes Resident Shared Private Permissions Mapped File 00022000 24 24 - 24 read/write/exec [ heap ] RESULT - THE Private memory allocated previously does NOT get Freed [ heap ] continues to be 24 K STEP 3 - allocating [30720] bytes pmap -x PID of Above Program process Address Kbytes Resident Shared Private Permissions Mapped File 00022000 32 32 - 32 read/write/exec [ heap ] STEP 4 - Freeing the memory allocated in the above Step Freeing [2] pmap -x PID of Above program process Address Kbytes Resident Shared Private Permissions Mapped File 00022000 32 32 - 32 read/write/exec [ heap ] RESULT - THE Private memory allocated previously in Step 3 does NOT get Freed [ heap ] continues to be 32 K Thanks -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: VIVEK_SHARMA INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note