From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261544AbVGWMbh (ORCPT ); Sat, 23 Jul 2005 08:31:37 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261609AbVGWMbh (ORCPT ); Sat, 23 Jul 2005 08:31:37 -0400 Received: from 167.imtp.Ilyichevsk.Odessa.UA ([195.66.192.167]:12450 "HELO port.imtp.ilyichevsk.odessa.ua") by vger.kernel.org with SMTP id S261544AbVGWMbf (ORCPT ); Sat, 23 Jul 2005 08:31:35 -0400 From: Denis Vlasenko To: "John Pearson" , "Erik Mouw" , "Ashley" Subject: Re: Kernel cached memory Date: Sat, 23 Jul 2005 15:31:20 +0300 User-Agent: KMail/1.5.4 Cc: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200507231531.20377.vda@ilport.com.ua> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Saturday 23 July 2005 00:43, John Pearson wrote: > Wouldn't having (practically) all your memory used for cache slow down > starting a new program? First it would have to free up that space, and then > put stuff in that space, taking potentially twice as long. I think there > should be a system call for freeing cached memory, for those that do want to > do it. I think this one is good enough: #include int main() { void *p; unsigned size = 1<<20; unsigned long total=0; while(size) { p = malloc(size); if(!p) size>>=1; else { memset(p, 0x77, size); total+=size; printf("Allocated %9u bytes, %12lu total\n",size,total); } } return 0; } You may want to adapt it so that it takes an argument now many megabytes to eat before it dies. -- vda