🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #2844

Locking/Unlocking memory

#2844
From: Brian Wyld
Date: Fri, 24 May 1991 11:02
42 lines
2658 bytes
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?
Technical Details
Message-ID: <1991May24.110224.27423@spider.co.uk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!nstn.ns.ca!news.cs.indiana.edu!att!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!wuarchive!uunet!mcsun!ukc!edcastle!spider!raft.spider.co.uk!brianw

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!nstn.ns.ca!news.cs.indiana.edu!att!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!wuarchive!uunet!mcsun!ukc!edcastle!spider!raft.spider.co.uk!brianw
From: brianw@orbweb.spider.co.uk (Brian Wyld)
Newsgroups: comp.windows.ms.programmer
Subject: Locking/Unlocking memory
Keywords: locking, unlocking, memory
Message-ID: <1991May24.110224.27423@spider.co.uk>
Date: 24 May 91 11:02:24 GMT
Sender: news@spider.co.uk (USENET News System)
Organization: Spider Systems Limited, Edinburgh, UK.
Lines: 42
Originator: brianw@orbweb
Nntp-Posting-Host: orbweb.spider.co.uk