brianw@orbweb.spider.co.uk (Brian Wyld) (05/24/91)
Hi. I'm new to posting so no flames please! I'm working on a Windows 3 project just now, and I've a wee question concerning LOCKing that hopefully someone can give a definate answer to. My application will only be running on 386SX or higher, so I'm not worries about 8088, 8086, 80286 etc. Enhanced mode protected operation only. When using ALLOC'd memory (local or global) there seem to be two schools of thought. 1) Just alloc your memory at the start of your application, lock it down and use the blocks like ordinary memory near or far pointers. Reasons: a) Windows currently doesn'y shuffle memory around at all b) It doesn;t matter if it does cause in enhanced mode it can do so without screwing up your far pointers anyway. c) It reduces the chances of you having a code path that forgets to unlock and crashing windows when it trys to free. d) The code looks so much better without these endless locks/unlocks and it'll be FASTER! 2) ALWAYS lock and unlock your memory when you actually use it. NEVER leave any piece of memory locked between WndProc calls. Reasons: a) Ok, just now windows doesn't seem to care or waste your pointers, but what about in the future? b) MS TELL you to do it like this (not that their apps do so, but when have MS every followed their own rules?) c) It won't clutter up memory with locked down objects. OK - which do I go for? I can see that probably just now 1) will work, esp. as my app is probably the only one running. HOWEVER, I'm a bit scared of the future - I'd like to still to work on a New Technology OS/2 v7.0 running on a transputer matrix (or whatever) without having to go through and put in all the locks/unlocks later. What do the rest of youse do? Brian Wyld !Spider Systems Ltd ! email: brianw@spider.co.uk !Stanwell St ! !Edinburgh, Scotland ! These are my opinions - who else !031 554 9424 ! would want them?