From mint-bounce@lists.fishpool.fi Wed Oct 12 16:50:03 2005 X-Original-To: fnaumann@mail.boerde.de Delivered-To: fnaumann@mail.boerde.de Subject: Re: [MiNT] Mshrink From: Evan Langlois To: mint@fishpool.com, Ingo Schmidt In-Reply-To: <1797962665.20051012130213@der-ingo.de> References: <1797962665.20051012130213@der-ingo.de> Content-Type: text/plain Date: Wed, 12 Oct 2005 09:47:45 -0500 Message-Id: <1129128465.15213.7.camel@taro.coolrunningconcepts.com> Mime-Version: 1.0 X-Mailer: Evolution 2.2.3 Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - esc14.midphase.com X-AntiAbuse: Original Domain - fishpool.com X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - CoolRunningConcepts.com X-Source: X-Source-Args: X-Source-Dir: X-ecartis-version: Ecartis v1.0.0 Sender: mint-bounce@lists.fishpool.fi Errors-To: mint-bounce@lists.fishpool.fi X-original-sender: Evan@CoolRunningConcepts.com Precedence: bulk List-help: List-unsubscribe: List-Id: X-List-ID: X-Virus-Scanned: by amavisd-new at relay.boerde.de X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on relay.boerde.de X-Spam-Status: No, hits=1.7 tagged_above=-50.5 required=7.0 tests=AWL, BAYES_01, RCVD_IN_SORBS X-Spam-Level: * On Wed, 2005-10-12 at 13:02 +0200, Ingo Schmidt wrote: > Hi all! > > Mshrink usually shrinks a malloced block of RAM. In MagiC, however, it > can also increase the ram block size. Mshrink is only there because the OS doesn't know how much memory is initially required for stack and heap, so it gives you the largest free block on program load. You then have to shrink that block down to what you actually need on start-up. Its not for general dynamic memory allocation. > Can this be done in MiNT, too. If not, why? The real is question is why, not why not. Just allocate what you need, and no more. Don't change it later if at all possible. Better yet, there should be a malloc() you are using that fetches large blocks using Malloc() and doles out the smaller sizes you need, and can handle memory block resizes much better than returning this memory directly to the OS where another process could take it. Using Mshrink() more than necessary or allocation of lots of small blocks through Malloc() could cause memory fragmentation issues.