From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10344 Path: news.gmane.org!.POSTED!not-for-mail From: "John Levine" Newsgroups: gmane.linux.lib.musl.general Subject: Re: application frequently map and unmap memory Date: 2 Aug 2016 17:36:49 -0000 Message-ID: <20160802173649.55362.qmail@ary.lan> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1470159451 12794 195.159.176.226 (2 Aug 2016 17:37:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 2 Aug 2016 17:37:31 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-10357-gllmg-musl=m.gmane.org@lists.openwall.com Tue Aug 02 19:37:27 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1bUdd8-0002v9-77 for gllmg-musl@m.gmane.org; Tue, 02 Aug 2016 19:37:26 +0200 Original-Received: (qmail 30566 invoked by uid 550); 2 Aug 2016 17:37:24 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 30540 invoked from network); 2 Aug 2016 17:37:23 -0000 In-Reply-To: X-Headerized: yes Xref: news.gmane.org gmane.linux.lib.musl.general:10344 Archived-At: In article 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