Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!pasteur!ucbvax!CORY.BERKELEY.EDU!dillon
From: dillon@CORY.BERKELEY.EDU (Matt Dillon)
Newsgroups: comp.sys.amiga
Subject: Re: gladiator from hell
Message-ID: <8809242137.AA14644@cory.Berkeley.EDU>
Date: 24 Sep 88 21:37:43 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Lines: 27


>let's say I want to alloc several blocks of mem. Is it better to do an 
>allocmem for each of them ? (so for 2 bitplanes and 1 copper list I would call
>alloc mem 3 times and fremem 3 times at the end )
>or just use 1 huge alloc mem (then I would use an alloc mem 17k. long ,
>bitplane 1 would be at the address returned by the alloc mem func, bp_2 would
>be at that address + 8k and the copper list at the original adress + 16 )
>and only 1 freemem would be needed.
>In the first case , a fragmemted memory (utilites floating around the memory)
>would cause less failure to occur in the alloc mem process. But it takes time
>(relatively) to free all the blocks. 
>In the second time, time is saved (1 alloc mem insstead of 3) but if there are
>no free contiguous memory of the required size, it would fail . 
>
>So what is better ? 

	For blocks of the size you want, allocate them separately.  It takes
the same amount of memory to allocate a reasonably sized blocks all at once vs
each separately, and as you said, larger allocate's might fail due to
memory fragmentation.

	FreeMem() is not slow.  Freeing 10000 small memory blocks may take
a while, but you would not notice the difference between 1 and 3 ... or 1 and
50 for that matter.  The block size does NOT effect how fast FreeMem()
runs.

					-Matt