Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!sun-barr!apple!well!brent From: brent@well.UUCP (Brent Southard) Newsgroups: comp.windows.ms Subject: Re: Memory Management & Data Structures Keywords: linked lists, moveable data segments Message-ID: <12962@well.UUCP> Date: 1 Aug 89 18:17:13 GMT References: <3033@blake.acs.washington.edu> Reply-To: brent@well.UUCP (Brent Southard) Distribution: comp.windows.ms Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 36 In article <3033@blake.acs.washington.edu> ano@blake.acs.washington.edu (John Michael Ano) writes: >........... Is it wiser to allocate one big block and do lots of pointer >arithmetic to maintain the list, or should I allocate one small block for >each element and use the handles generated by LocalAlloc() to get pointers >(with LocalLock()) to adjacent nodes? I know you've heard this before, but it can't be stressed enough: Keep memory objects unlocked. This is not as big a deal in the local heap as it is in global memory, but it is proper. You may want to consider using global memory from the start in case your memory needs increase (the way they always do). >The drawback with the second method >is that I have to lock and unlock each node to traverse the list. It seems >awkward, but Petzold mentions that the GlobalLock and GlobalUnlock functions >are fairly fast, and I assume the same applies to the local versions even >though he says nothing about them. Yes, the lock/unlock functions are pretty quick. However, you may find the real drawback is the meomory overhead Windows associates with allocated memory blocks. I believe there is something like a 16-byte block associated with each global handle (though I could be way off!). >The allocated blocks are all allocated as LM_MOVEABLE so that Windows can move >the blocks when memory gets scarce. How have other people dealt with data >structure management under Windows? Yes. Isn't it fun? Let's hope 3.0 eases things a bit... brent -- brent southard (313) 656-8349 | oh mona mona ImageTech Corp (313) 362-3141 | you can close your eyes | i've got a twelve gauge surprise usenet: ...!well!brent | waiting for you -- James Taylor