🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms
Article #1852

Re: Generic in Large Model

#1852
From: Michael Thurlkill 1/1029
Date: Wed, 04 Oct 1989 16:47
61 lines
4100 bytes
In article <1464@quiche.cs.mcgill.ca> chryses@quiche.cs.mcgill.ca (Phong CO) writes:
>Hi, I am new to the net and have a couple of questions to ask:
>
>1) I have Windows/286 2.11, and the Software Developement Kit.  I tried
>to compile the Generic program under the large module.  I changed the
...
As mentioned by a few other people, this is not recommended. There are
few instances where you HAVE to use large model. By using medium model,
you will be able to have multiple code segments, but only one data
segment. However, you can GlobalAlloc additional blocks of memory as
needed. This is what PageMaker, Excel, Designer, etc. etc. do. If you
are starting an application, it is to your advantage to start with
medium model.
The one case I have seen where it is valid to use large model, is 
when converting an existing large model app. It is advantageos to
eventually convert to medium model, but you can get things working
initially in large model. The basic requirements are: make all data
segments FIXED, and increase the stack size (doubling is a safe bet).
Since large model makes all data references FAR, the reference is 
resolved at load time. If the data moves, the reference is invalid, 
but doesn't get fixed up. Thus the fixed requirement. The stack must
be larger because pointers and other data items are larger.
Expect performance to be severly degraded if you go with large model.
Since you have many fixed memory objects, it is harder for Windows 
to move memory around to fullfill allocation requests, so it takes 
more time.           

>
>2)  I want to write a program that will, at startup, allocate a (very)
>large block of memory, say about 4MB.  I intend to use this as a heap,
>and have my own heap management functions.  The block will be locked as
>soon as it is allocated, and unlocked when the program terminates.  The
>fact that I won't be able to run anything else in the meantime is not a
>problem.  The problem is that GlobalAlloc fails with that amount.  
>Microsoft Tech Support claims that data size depends on extended memory
>size, since data segments are not swapped.  I currently have 2MB of 
>extended memory on my AT, most of which has been given to SMARTdrv.  Is
>there a way to manage this block of memory?
>
Under the current version of Windows, you are constrained to the 640k
conventional memory space. If you are using expanded memory (or 
virtualizing extended memory as expanded), code and data will be banked
to expanded memory, but each application will have access to at most 
640k. Therefore, you can run multiple applications to consume your
2MB of extended, but your application will be able to GlobalAlloc a
maximum of probably 200-400k. As mentioned by another person, you 
should try to break up your data in order to better utilize memory.
You still have the same allocation limit though. If you MUST     
allocate a larger amount than you can get via GlobalAlloc, you may want
to look into making direct expanded memory calls. You can only make
LIM 3.2 calls in a Windows application, and the app must be RCed with
the -L switch. You can find information on the LIM api in the 
MS-DOS Encyclopedia, and various other references. Since you only have
2MB of memory, you still won't be able to allocate 4MB of memory.
Oh yeah, remember that if you GlobalAlloc a block larger that 64k,
it should be fixed, and should be accessed with a HUGE pointer.

Mike

Disclaimer: These thoughts and opinions are my own. They should not
be mis-construed to be correct or in any way related to my employer.
Technical Details
Message-ID: <7952@microsoft.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!microsoft!michaelt
References: <1464@quiche.cs.mcgill.ca>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!microsoft!michaelt
From: michaelt@microsoft.UUCP (Michael Thurlkill 1/1029)
Newsgroups: comp.windows.ms
Subject: Re: Generic in Large Model
Message-ID: <7952@microsoft.UUCP>
Date: 4 Oct 89 16:47:41 GMT
References: <1464@quiche.cs.mcgill.ca>
Reply-To: michaelt@microsoft.UUCP (Michael Thurlkill 1/1029)
Organization: Microsoft Corp., Redmond WA
Lines: 61