Mail Archives: djgpp/1998/06/02/19:00:42
Daniel Delorme wrote:
>
> I've searched the djgpp mailing list archives and found interesting
> stuff on disabling virtual memory and getting memory information from
> the system (_go32_dpmi_get_free_memory_information)
>
> My problem is: I want a way to know when all the physical memory is
> used up so I can compress the data I'm working on (random map generation)
> and go on processing without having to hear the sweet music of swapping
>
> In DOS mode (using CSWDPMI), I can use _go32_d[..].available_physical_pages
> The problem is with Win95 (how suprising) : available_physical_pages never
> reaches zero even after the swapping starts.
>
> If you know an alternative solution to prevent swapping, I'd love to hear
> about it !
You can force all allocated memory to be locked by using the
_crt0_startup_flags variable (look it up in the libc reference).
Basically, you include the following code in the main module of your
program:
#include <crt0.h>
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.
--
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I | mailto:fighteer AT cs DOT com |
| Proud owner of what might one | http://www.cs.com/fighteer/ |
| day be a spectacular MUD... | ICQ UIN#: 7406319 |
| Plan: To make Bill Gates suffer | HEAT User ID: Fighteer |
---------------------------------------------------------------------
- Raw text -