From owner-freebsd-hackers Thu Sep 23 2: 4:38 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by hub.freebsd.org (Postfix) with ESMTP id E57461595F for ; Thu, 23 Sep 1999 02:04:33 -0700 (PDT) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.9.3/8.9.1) id CAA23644; Thu, 23 Sep 1999 02:04:22 -0700 (PDT) (envelope-from dillon) Date: Thu, 23 Sep 1999 02:04:22 -0700 (PDT) From: Matthew Dillon Message-Id: <199909230904.CAA23644@apollo.backplane.com> To: Kevin Day Cc: dcs@newsguy.com (Daniel C. Sobral), toasty@dragondata.com (Kevin Day), hackers@FreeBSD.ORG Subject: Re: Idea: disposable memory References: <199909230624.BAA94111@celery.dragondata.com> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG :> > Thoughts? :> :> man madvise? :> : :Yeah, but MADV_FREE doesn't really do what I need. I have no idea if the :system actually did free my ram or not. I want to hang on to the data, but :if more ram is needed, then it can be discarded, but I need to know that it :did, so that I can recreate it. Checking every time I blit an object to see :if the page is zero'ed won't work. : :Kevin madvise ... MADV_DONTNEED is what you want. The data will remain mapped until the system reuses it, at which point it reverts to zero-fill. The system will reuse the data fairly quickly, even if the system is not all that loaded. You can lock the page back in simply by writing to something in the page. The system implements this madvise feature by marking the pages clean. If you happen to write to the page before the system reuses it, it of course gets redirtied. If you don't and the system reuses the page, it goes bye bye (turns into zero-fill) from the point of view of your process. -Matt Matthew Dillon To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message