mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Denis Vlasenko <vda@ilport.com.ua>
To: "John Pearson" <john@illhostit.com>,
	"Erik Mouw" <erik@harddisk-recovery.com>,
	"Ashley" <ashleyz@alchip.com>
Cc: <linux-kernel@vger.kernel.org>
Subject: Re: Kernel cached memory
Date: Sat, 23 Jul 2005 15:31:20 +0300	[thread overview]
Message-ID: <200507231531.20377.vda@ilport.com.ua> (raw)
In-Reply-To: <JCEEICIEKCENOEGFMGBACEAGCAAA.john@illhostit.com>

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 <stdlib.h>

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


  reply	other threads:[~2005-07-23 12:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-22  9:46 Ashley
2005-07-22 11:31 ` Diego Calleja
2005-07-22 12:57 ` Erik Mouw
2005-07-22 21:43   ` John Pearson
2005-07-23 12:31     ` Denis Vlasenko [this message]
2005-07-22 13:25 ` Gábor Lénárt
2005-07-22 17:58   ` Lee Revell
2005-07-23 10:50     ` Oliver Neukum
2005-07-25 16:47   ` Bill Davidsen
2005-07-25 17:03     ` Diego Calleja
2005-07-25 17:07     ` Paolo Ornati
2005-07-25 18:02       ` Bill Davidsen
2005-08-01 10:38     ` Gábor Lénárt
2005-08-01 21:08       ` Bill Davidsen
2005-07-26  0:35 Chuck Ebbert
     [not found] <4t5s8-68A-33@gated-at.bofh.it>
     [not found] ` <4tdIU-479-9@gated-at.bofh.it>
2005-07-26  5:03   ` Robert Hancock
2005-07-26 15:00     ` Bill Davidsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200507231531.20377.vda@ilport.com.ua \
    --to=vda@ilport.com.ua \
    --cc=ashleyz@alchip.com \
    --cc=erik@harddisk-recovery.com \
    --cc=john@illhostit.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®