mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "John Levine" <johnl@taugh.com>
To: musl@lists.openwall.com
Subject: Re: application frequently map and unmap memory
Date: 2 Aug 2016 17:36:49 -0000	[thread overview]
Message-ID: <20160802173649.55362.qmail@ary.lan> (raw)
In-Reply-To: <CAAKbDrdMVskT=Azgnu6DPUpAbJa_gToUcq-jjCvRKe7CJmJ22g@mail.gmail.com>

In article <CAAKbDrdMVskT=Azgnu6DPUpAbJa_gToUcq-jjCvRKe7CJmJ22g@mail.gmail.com> you write:
>I am looking for real-world applications
>I guess if some applications use large chunk of memory, map and unmap
>are necessary.
>I just am not aware which applications have such requirements.

If you just want to use a large chunk of memory, malloc() and free()
work fine.  Memory mapping is for situtations where you need to share
data between applications, or you want to do something on a whole file
so it's more efficicient to map the file into memory than to use reads
and writes.

My version of grepcidr uses mmap so it can scan through whole files as
fast as possible.  It's like the usual grep utility but specialized to
look for IP addresses, typically in large log files.

http://www.taugh.com/grepcidr-2/

It uses a state machine to scan through each file which never backs up
by more than one character so its usage is map a file, scan through
the whole thing sequentially, unmap it, map in the next file, and so
forth.

R's,
John


      reply	other threads:[~2016-08-02 17:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-01 22:06 Yuxin Ren
2016-08-02 16:18 ` Rich Felker
2016-08-02 16:58   ` Yuxin Ren
2016-08-02 17:36     ` John Levine [this message]

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=20160802173649.55362.qmail@ary.lan \
    --to=johnl@taugh.com \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).