bmacintyre@watcgl.waterloo.edu (Blair MacIntyre) (05/04/89)
Because the Amiga has no MMU, etc., we get memory fragmentation as we allocate/deallocate, right? So, what I'm wondering is this: If I want to do alot of small allocs/frees, am I going to fragment memory beyond belief? I'm thinking of something on the order of alocating a new line buffer every time a line is changed ( including freeing the old one ). That isn't exactly the use, but it is about the frequency. Would it be better to manage my own free pool? I don't like the concept of pre-allocating large chunks, however. Does the system unify adjoining blocks of free memory into bigger blocks? It seems to me that I _shouldn't_ have to worry about this stuff, but for some reason I am ... Blair -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-///-= = Blair MacIntyre, bmacintyre@watcgl.{waterloo.edu, UWaterloo.ca} \\\/// = = now appearing at the Computer Graphics Lab, U of Waterloo! \XX/ = = "Don't be mean ... remember, no matter where you go, there you are." BBanzai=
cmcmanis%pepper@Sun.COM (Chuck McManis) (05/05/89)
In article <9504@watcgl.waterloo.edu> (Blair MacIntyre) writes: > Because the Amiga has no MMU, etc., we get memory fragmentation >as we allocate/deallocate, right? So, what I'm wondering is this: Not exactly. >If I want to do alot of small allocs/frees, am I going to fragment >memory beyond belief? I'm thinking of something on the order of >alocating a new line buffer every time a line is changed ( including >freeing the old one ). That isn't exactly the use, but it is about >the frequency. This won't necessarily affect fragmentation, if there isn't much other activity going on then you will be fine. However if another task allocates a 32K chunk, then you allocate a line buffer, and then that task frees it's 32K chunk it will sit there as a fragment until you free your line buffer. >Would it be better to manage my own free pool? I don't like the >concept of pre-allocating large chunks, however. Depends on the application, in the case of line buffers it makes more sense for you to do so since your internal allocator will probably be faster than AllocMem. >Does the system unify adjoining blocks of free memory into bigger >blocks? Yes. >It seems to me that I _shouldn't_ have to worry about this stuff, >but for some reason I am ... Two biggest problems with memory allocation on the Amiga are, first if you stomp the memory list (write at a negative offset from the memory chunk you got) you can confuse the allocater into thinking memory is hosed. Second, if you use AllocRemember() and call FreeRemember(,0) then it doesn't free the little 8byte chunks that have the list headers associated with them and that will fragment memory. --Chuck McManis uucp: {anywhere}!sun!cmcmanis BIX: cmcmanis ARPAnet: cmcmanis@sun.com These opinions are my own and no one elses, but you knew that didn't you. "A most excellent barbarian ... Genghis Kahn!"
mcp@ziebmef.uucp (Marc Plumb) (05/13/89)
The worst case for memory fragmentation is to make many allocations and free every other one. If you're allocating a lot of small elements but freeing them all at about the same time, all is well. If you allocate a bunch of permanent blocks, and then a lot of temporary ones which get thrashed a lot, it's still not too bad. It's when you mix everything up (like in a Lisp run-time - you may not know at allocation time even approximately how long the storage will be needed) that it gets trashed. -- -Colin Plumb (mcp@ziebmef.uucp)