From: "Patrick R. McManus" <mcmanus@ducksong.com>
To: Andrew Morton <akpm@digeo.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Memory Measurements and Lots of Files and Inodes
Date: Wed, 11 Dec 2002 19:21:10 -0500 [thread overview]
Message-ID: <20021212002110.GA27532@ducksong.com> (raw)
In-Reply-To: <3DF7D3BE.59F4B212@digeo.com>
[Andrew Morton: Dec 11 16:09]
> "Patrick R. McManus" wrote:
> >
> > ...
> > Just sitting back and watching vmstat while this runs my 'free' memory
> > drops from ~600MB to about ~16MB.. the buffers and cache remain roughly
> > constant.. at 16MB some sort of garbage collection kicks in - there is
> > a notable system pause and ~70MB moves from the used to the 'free'
> > column... this process repeats more or less in a steady state.
>
> Probably `negative dentries' - cached directory entries which say
> "this file isn't there" so we don't need to go into the fs to
> find that out.
>
> If you could share your test apps that would help a lot.
sure! this is the "lots of files" program.
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define BSZ 2000
unsigned char buf[BSZ+256];
main ()
{
int fd,i,j;
unsigned int ctr=0;
unsigned char r=0;
char f1[32],f2[32],f3[32],f4[32];
while (1)
{
sprintf (f1,"fxa_%06d",ctr++); sprintf (f2,"fxa_%06d",ctr++);
sprintf (f3,"fxa_%06d",ctr++); sprintf (f4,"fxa_%06d",ctr++);
fd = open (f1,O_CREAT | O_RDWR);
memset (buf,r++,BSZ+256); write (fd,buf,BSZ+r); close (fd);
fd = open (f2,O_CREAT | O_RDWR);
memset (buf,r++,BSZ+256); write (fd,buf,BSZ+r); close (fd);
fd = open (f3,O_CREAT | O_RDWR);
memset (buf,r++,BSZ+256); write (fd,buf,BSZ+r); close (fd);
fd = open (f4,O_CREAT | O_RDWR);
memset (buf,r++,BSZ+256); write (fd,buf,BSZ+r); close (fd);
unlink (f1); unlink (f2); unlink (f3); unlink (f4);
if (!r)
fprintf (stdout,".");fflush (stdout);
}
}
and this is the "gimme 300MB even though free sez I hardly have
anything" program:
#define BS (30*1024*1024)
main()
{
char *x;
x = malloc (BS);
if (!x)
printf ("heh - x is NULL\n");
else
{
printf ("allocd\n");
memset (x,0x31,BS);
printf ("set\n");
free (x);
printf ("freed\n");
}
}
> On your machine it'll be "all of swap plus all of physical memory
> minus whatever malloc'ed memory you're using now minus 8-12 megabytes".
> There isn't much memory which cannot be reclaimed unless you have a
> huge machine or you're doing odd things.
this is useful advice, thanks. Basically what the new procps does?
next prev parent reply other threads:[~2002-12-12 0:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-11 23:52 Patrick R. McManus
2002-12-12 0:09 ` Andrew Morton
2002-12-12 0:21 ` Patrick R. McManus [this message]
2002-12-12 0:27 ` Andrew Morton
2002-12-13 8:39 ` David Schwartz
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=20021212002110.GA27532@ducksong.com \
--to=mcmanus@ducksong.com \
--cc=akpm@digeo.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
Powered by JetHome