Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!cs.utexas.edu!uunet!microsoft!roberth From: roberth@microsoft.UUCP (Robert Hess) Newsgroups: comp.windows.ms Subject: Re: Generic in Large Model Summary: Windows and LARGE model don't mix Message-ID: <7887@microsoft.UUCP> Date: 29 Sep 89 15:33:09 GMT References: <1464@quiche.cs.mcgill.ca> Organization: Microsoft Corp., Redmond WA Lines: 91 Phong, (he had a couple questions about writing a Windows program that used LARGE memory model...) First off, a comment on using the LARGE memory model... *** DON'T *** I have yet to see a program that actually needs to use the LARGE memory model (and I've seen a lot of programs). I'm sure many of you will agree that Aldus PageMaker is a rather large application, and has some pretty awsome data and code demends. It uses MEDIUM model. I can't count the number of times that a developer has tried to convince me that they needed to use the LARGE memory model, yet I easily showed them how they could not only use MEDIUM, but get their program running faster, and more optimumly as well. When you 'own' the CPU, the LARGE model can make sense. You KNOW exactly what is being done when, and by who. (You control the Horizontal, You control the Vertical...) In Windows, you are not in control of what code is running, or where it is running from. You don't know when data swapping is needed, you don't know where it is going to be swapped to, and you don't know what other operations the user is trying to accomplish. Hopefully I have gotten my point across without needing to bring out a 2x4, now to your questions: > 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 > makefile by adding the -AL switch to the MSC 5.1, and changed the > library from slibw to llibw. I also added a menu to the resource file. > The pro- gram compiles and runs fine, except that the menu does not show > up. It does show up if I return to the small model. Is there something > else I should modify or include somewhere? Unfortunately, my system is no longer set up to compile Windows, and I have not tried to do this myself (for good reasons), so I can only give you a guess. Your stack is too small. This is just one of the MANY problems that you will come across when trying to use the LARGE memory model. > 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? Am I missing something here, are are you asking how to allocate 4mb of memory on a machine that doesn't even have 2mb available? How much free memory does GlobalCompact tell you is available? There is no way that GlobalAlloc will allow you to access more memory then that. Even on a Large Mainframe computer, it is rarely adviseable to simply allocate that large of a chunk of memory and just 'use' it. It is always preferable to use some sort of memory blocking algorithm to contain your memory in smaller segments. You will be using smaller addressing, thus faster access, you will only be allocating/initializing the memory as the user is needing it, thus increasing the apparent speed of the program. And depending on your method, you will also be safer in case of a system failure, because you may be storing your temporary data in a virtual memory file on disk. If you *MUST* use LARGE memory model, first go see a shrink, then talk your school into getting a Microsoft OnLine account (=~$800). You will need to get direct support from Microsoft to help you identify and work around the problems that you will encounter. I know that there are several other universities that have accounts (maybe yours already has one). -Robert __________________________________________________________________________ ##### ####### | Robert B. Hess, Microsoft Corp., Redmond, WA ###### ####### |----------------------------------------------------- ####### ####### | roberth@microsof.uu.net #### ##### #### | {decvax, uunet, uw-beaver}!microsof!roberth #### ### #### |_____________________________________________________ "...my opinions are strictly my own, and not those of my employer..."