🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms
Article #13870

Re: Memory Questions

#13870
From: Paul Moody
Date: Fri, 22 Dec 1989 14:28
36 lines
2184 bytes
In article <25230@cup.portal.com>, AnchorMan@cup.portal.com (Brian Keith Carlisle) writes:
> 
> I'm writing a Windows bases program in C and I declare several global
> variables.  Where are these global variables put?  If they're put in the 
> data segment, and I don't have to go through the "get handle, local lock/
> global lock, etc.," how can I be sure that these variables are valid (since
> my data segment can be moved by Windows)?
> 
> Also, as long as I'm asking questions, what are the advantages and 
> disadvantages of Global Memory & Local Memory?

Global external(static) memory lives in your data segment, offset from
register DS. Windows Global Memory lives 'out there' and is offset
from register ES. Windows Local Memory is also in your data segment
offset from register DS. Automatic variables live on the stack.

Windows can do two different types of data moveing on DS based
memory. First, from one message to the next, the entire DS segment
could move, the value in the DS register changes. The second is more
complex. 

When your program starts, all external statics, declared outside of
any function, are allocated. Your data segment is allocated memory
equal to that plus the heap size you specified in your .def file plus
some that windows needs for its own housekeeping. The external statics
are not touched by windows. Any unlocked Local heap variables that are
marked as moveable can be moved if windows needs the space.

Local memory is easier to use than global memory, but it is a limited
resource. If you want to share data with other apps, you must use
global memory.

-- 
Paul Moody			UUCP: rutgers!cscnj!paul 
Computer Sciences Corporation
# the opinions expressed are entirely imaginary			#
Technical Details
Message-ID: <607@cscnj.csc.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!sun-barr!rutgers!cscnj!paul
References: <25230@cup.portal.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!sun-barr!rutgers!cscnj!paul
From: paul@cscnj.csc.COM (Paul Moody)
Newsgroups: comp.windows.ms
Subject: Re: Memory Questions
Summary: global statics vs GloabalMemory
Message-ID: <607@cscnj.csc.COM>
Date: 22 Dec 89 14:28:06 GMT
References: <25230@cup.portal.com>
Distribution: usa
Organization: Computer Sciences Corp., Piscataway NJ
Lines: 36