[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] Mshrink
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.