cmcmanis%pepper@Sun.COM (Chuck McManis) (09/27/88)
Walter Dao asked if it was better to allocate memory in one big chunk or a piece at a time as you needed it. The answer is "It depends." and the tradeoffs are as follows : If you allocate memory in exactly the sizes you need it, when you need it you have a better chance of running on memory fragmented machines. This is because the allocator has a chance to give you those little fragments that are out there. On a large unfragmented system, there is no benefit and the process is slower because it takes time for each allocation. In this case it is often better to get one big allocation and then use the pieces out of it that you need. In all cases it is probably better to allocate chunks in sizes of 512 bytes or more. But of course that is sometimes not possible. If you are worried about it, try the large allocation first, and if that fails try it one more time (someone may have expunged themselves for you), and then go for the smaller pieces. --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.