Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!pcad!rob From: rob@pcad.UUCP (Ralph Brown) Newsgroups: comp.windows.ms.programmer Subject: Re: Allocating a lot of memory (why can't I?) Summary: No joy Message-ID: <522@pcad.UUCP> Date: 13 May 91 18:49:42 GMT References: <518@pcad.UUCP> <72271@microsoft.UUCP> Organization: Personal CAD Systems, Westford, MA Lines: 46 In article <72271@microsoft.UUCP>, donc@microsoft.UUCP (Don CORBITT) writes: > > I'm not sure what's happening on your systems. It is possible your heap > is filled with pagelocked objects, but real unlikely. Are you calling > GlobalAlloc(), or are you calling GlobalCompact(0)? Note that under > Enchanted mode, GlobalCompact() doesn't really compact the heap, it just > tells you the largest block you can get _without_ compacting. This is > on purpose, since compacting the heap on a page-swapping system takes a > lot of time and disk access. If you really want a lot of memory, just > allocate it. This will convince Windows that you are serious, and force > heap compaction. > > I'm able to routinely allocate 4 MB (and sometimes 8MB) on my system with > 8MB ram, (6MB available to Windows). You should be able to, also. > -- > Don Corbitt, MSWinDev What I`m seeing seems pretty odd. My program just does a GlobalCompact(0), and a GetFreeSpace to see what Windows will admit to. It uses a starting memory size and and increment value both of which start at 1 Meg. It then attempts to GlobalAlloc the memory size amount, and if it succeeds, adds the increment to the size, frees the previous block and tries again. If it fails, it goes back to the last size that worked, cuts the increment in half, and tries again. What I see when I run this (confirmed by heapwalker) is the first time I run, I get 1.3 Meg. I then reset everything (without exiting), and try again. The second or third time I run, I consistantly get 3.5 Meg and from then on in the same session, it alternates between 1.3 and 3.5. However, if I'm in one of the passes where I've gotten over 2 MB, if I reset without exiting I can consistantly get at least 3 MB every time. If I continue asking for larger blocks till it fails on a GlobalAlloc, then I have to go through a cycle of 1.3M. The results for max memory are: 1.3 1.3 3.5 1.3 3.5 1.3 3 3 3 3 3 3.5 1.3 3.5 ... If I reduce my swapfile size so there's only 3 MB free when I start, the same behavior occurs, however it is at lower values of 1.1 MB and 2 MB. Do you have a large swap file? You said that occasionally you can get 8MB, normally 4 MB. What distinguishes these two cases? Ralph