Message-Id: <3.0.3.32.19980603141855.0068cd44@ns.coba.net> Date: Wed, 03 Jun 1998 14:18:55 -0400 To: djgpp AT delorie DOT com From: Daniel Delorme Subject: Re: I don't want swapping In-Reply-To: <35748327.36E0@cs.com> References: <3 DOT 0 DOT 3 DOT 32 DOT 19980602183929 DOT 006ad4e4 AT ns DOT coba DOT net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Precedence: bulk John M. Aldrich wrote: > >#include > >int _crt0_startup_flags = _CRT0_FLAG_LOCK_MEMORY; > >When you do this, all allocated memory will be prevented from paging; >thus, when you run out of unlocked memory, malloc() and company will >fail. > Have you tried this with Win95 ? I've run my program (included below) on 64MB of RAM and it seems that the DOS box can always allocate 64MB of locked memory. I ran the program in 2 dos boxes simultaneously and I could allocate 64MB of LOCKED memory in EACH before getting NULL from malloc(). But even if you're not looking for problems, locking memory only makes sure there won't be swapping within the program. The other stuff in memory (win95, applications, etc...) CAN be swapped out and I want to prevent this delay too. Anybody knows another solution? #include #include #include #include int _crt0_startup_flags = _CRT0_FLAG_LOCK_MEMORY; main() { unsigned long pm,vm; int i = 0; int *Ptr[1000]; _go32_dpmi_meminfo meminfo; do { i++; Ptr[i] = malloc(2*1024*1024-4); pm = _go32_dpmi_remaining_physical_memory(); vm = _go32_dpmi_remaining_virtual_memory(); _go32_dpmi_get_free_memory_information(&meminfo); clrscr(); printf("#%d (%08x)\n", i, Ptr[i]); printf("available memory = %10d\n", meminfo.available_memory); printf("available pages = %10d\n", meminfo.available_pages); printf("available lockable pages = %10d\n", meminfo.available_lockable_pages); printf("linear space = %10d\n", meminfo.linear_space); printf("unlocked pages = %10d\n", meminfo.unlocked_pages); printf("available physical pages = %10d\n", meminfo.available_physical_pages); printf("total physical pages = %10d\n", meminfo.total_physical_pages); printf("free linear space = %10d\n", meminfo.free_linear_space); printf("size of paging file = %10d\n", meminfo.max_pages_in_paging_file * 4096); printf("remaining physical memory = %10d\n", pm); printf("remaining virtual memory = %10d\n\n", vm); } while (Ptr[i] && getch() != 27); while (i > 0) { free(Ptr[i]); i--; } }