From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <97446234521124.tru64-unix-managers.marc@archive.invalid> From: Nikola Milutinovic Date: Fri, 17 Nov 2000 11:57:01 +0000 To: tru64-unix-managers Subject: [Fwd: Memory Management] X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=97446234521124 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--------------54DBB41815B995E0EE275662" This is a multi-part message in MIME format. --------------54DBB41815B995E0EE275662 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi all. There was an unusual problem noted on the news:comp.unix.tru64. A process allocates memory, dynamically. This causes VSIZE of the process to increase. When the memory is freed, the VSZIE doesn't decrease. The reported behaviour from 3.2 was that it would decrease. I have included the original post. I have tested this on 4.0D+PK6 and 4.0F+PK3, it shows the same dreaded behaviour. The test program I used was: #include #include #define MB (1024*1024) void main(void) { char *mem_block1; char *mem_block2; mem_block1 = (char *)malloc(50*MB); printf( "Should be at 50M+\n" ); getchar(); /* give chance to run ps */ mem_block2 = (char *)malloc(50*MB); printf( "Should be at 100M+\n" ); getchar(); /* give chance to run ps */ free(mem_block2); printf( "Should be at 50M+ again\n" ); getchar(); /* give chance to run ps */ } Compiled with "cc -o test.exe test.c" Inspection with "ps aux | grep test.exe | grep -v grep" Nix. -- True programmers never die, they just branch to an odd address. --------------54DBB41815B995E0EE275662 Content-Type: message/rfc822 Content-Transfer-Encoding: 7bit Content-Disposition: inline Path: Mercury.ev.co.yu!EUnet.yu!nmaster.kpnqwest.net!npeer.kpnqwest.net!news2.kpn.net!news.kpn.net!newsfeeds.belnet.be!news.belnet.be!btnet-peer1!btnet-peer0!btnet!news5-gui.server.ntli.net!ntli.net!news6-win.server.ntlworld.com.POSTED!not-for-mail Message-ID: <3A11AFE6.194B9261@virgin.net> From: root X-Mailer: Mozilla 4.72 [en] (X11; U; Linux 2.2.14-5.0 i686) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.unix.tru64 Subject: Memory Management Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Tue, 14 Nov 2000 21:34:30 +0000 NNTP-Posting-Host: 62.252.6.71 X-Complaints-To: abuse@virgin.net X-Trace: news6-win.server.ntlworld.com 974237693 62.252.6.71 (Tue, 14 Nov 2000 21:34:53 GMT) NNTP-Posting-Date: Tue, 14 Nov 2000 21:34:53 GMT Organization: Virgin Net Usenet Service Xref: Mercury.ev.co.yu comp.unix.tru64:671 This is a historic question. We upgraded from Tru64 3.2G to Tru64 4.0F some time ago. When we ran our application on 4.0F we started getting "Low swap space" warnings that we did not get under 3.2G. Looking at the VSIZE column of the 'ps' output I noticed that under 4.0F memory allocated to a process is not released back to the operating system - i.e. VSIZE only ever increases. Under 3.2G the VSIZE fluctuates up and down. I wrote the following simple test C program: #include #include #define MB (1024*1024) void main(void) { char *mem_block1; char *mem_block2; mem_block1 = (char *)malloc(50*MB); mem_block2 = (char *)malloc(50*MB); getchar(); /* give chance to run ps */ free(mem_block2); get_char(); /* give chance to run ps */ } Under 4.0F the VSIZE is approx 100Mb + some process overhead Under 3.2G the VSIZE is approx 50MB + some process overhead. Unfortunately I no longer have access to the 3.2G box. Does anyone know for certain if the memory management was changed from 3.2, in which malloc()/free() off-loaded all memory management to the kernel, and 4.0F which appears to expect the user processes to manage free space with malloc()/free()? I'm guessing this change (if I'm right) was made for kernel efficiency - for example, less scanning of free lists, less swap allocation/deallocation activity, etc. Regards, Hugh Patrick --------------54DBB41815B995E0EE275662--