From owner-freebsd-hackers@FreeBSD.ORG Wed Jan 6 23:33:24 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2420C1065672 for ; Wed, 6 Jan 2010 23:33:24 +0000 (UTC) (envelope-from pieter@degoeje.nl) Received: from mx.utwente.nl (mx3.utsp.utwente.nl [130.89.2.14]) by mx1.freebsd.org (Postfix) with ESMTP id 9EF408FC1D for ; Wed, 6 Jan 2010 23:33:23 +0000 (UTC) Received: from nox.student.utwente.nl (nox.student.utwente.nl [130.89.165.91]) by mx.utwente.nl (8.12.10/SuSE Linux 0.7) with ESMTP id o06NHbHH026701; Thu, 7 Jan 2010 00:17:37 +0100 From: Pieter de Goeje To: freebsd-hackers@freebsd.org Date: Thu, 7 Jan 2010 00:17:36 +0100 User-Agent: KMail/1.9.10 References: <5a13b8941001061349m701d17fbl489ec8cf883e8c3c@mail.gmail.com> In-Reply-To: <5a13b8941001061349m701d17fbl489ec8cf883e8c3c@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <201001070017.36855.pieter@degoeje.nl> X-UTwente-MailScanner-Information: Scanned by MailScanner. Contact icts.servicedesk@utwente.nl for more information. X-UTwente-MailScanner: Found to be clean X-UTwente-MailScanner-From: pieter@degoeje.nl X-Spam-Status: No Cc: shrivatsan Subject: Re: Question regarding memory disks X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jan 2010 23:33:24 -0000 On Wednesday 06 January 2010 22:49:44 shrivatsan wrote: > Hi, > > I have configured a malloc-backed memory disk, and I mount the device on to > the file system. I write some data onto the file system. I see that the > free memory indicated by kmem_map_free goes down, and this is proportional > to the size of the data written. However, even after removing all the > data, kmem_map_free doesn't seem to go up. Its only after detaching the > memory disk does the free memory go up. May I know the reason for this > behavior? > > > Thanks, > -shrivatsan Because when you "erase" something, all it does is unlink (delete the reference to) the data. So there is currently no way the memory disk can free the memory associated with the data. That is also why you should normally use swap backed memory disks instead, or use tmpfs. These can return memory to the system. The ability of the filesystem to mark certain blocks as "erased" is important not only for memory disks but also for solid state drives. It is a feature UFS2 is currently lacking unfortunately. - Pieter