delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/08/16/15:45:25

From: "Wim Cools" <wimcools AT wishmail DOT net>
Newsgroups: comp.os.msdos.djgpp
References: <8ndke0$lt8$4 AT info DOT cyf-kr DOT edu DOT pl>
Subject: Re: checking amount of free memory
Lines: 62
X-Newsreader: Microsoft Outlook Express 4.72.3155.0
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0
Organization: WISH B.V.
Message-ID: <966455601.744070@news.l3.wish.net>
Cache-Post-Path: news.l3.wish.net!unknown AT p9957 DOT nl DOT wish DOT net
X-Cache: nntpcache 2.4.0b2 (see http://www.nntpcache.org/)
Date: Wed, 16 Aug 2000 21:43:29 +0200
NNTP-Posting-Host: 212.123.129.69
X-Trace: server12-ams1 966455096 212.123.129.69 (Wed, 16 Aug 2000 20:44:56 BST)
NNTP-Posting-Date: Wed, 16 Aug 2000 20:44:56 BST
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

>Is it posible to check the amount of free memory in DJGPP ? Can You send me
>a small program that will print
>amount of free virtual, and free physical memory ?

#include <go32.h>
#include <stdio.h>
#include <dpmi.h>


#define free_memory ((info.available_physical_pages * 4096) / 1024)
#define total_memory ((info.total_physical_pages * 4096) / 1024)

/*
     typedef struct {
       u_long available_memory;
       u_long available_pages;
       u_long available_lockable_pages;
       u_long linear_space;
       u_long unlocked_pages;
       u_long available_physical_pages;
       u_long total_physical_pages;
       u_long free_linear_space;
       u_long max_pages_in_paging_file;
       u_long reserved[3];
     } _go32_dpmi_meminfo;
*/

int main()
{
       _go32_dpmi_meminfo info;
       _go32_dpmi_get_free_memory_information(&info);

       printf("Memory:\n");
       printf("free: %ld\n", free_memory);
       printf("total: %ld\n", total_memory);

       return 0;
}

>Why when running in windows Dos-Box my Djgpp program can't use disk space
to
>create more virtual memory,
>when physical memory is full ?

I don't think if this is actually true but I think so:

Windows has a Virtual Memory Manager of it's own. So, if you allocate memory
and there is no physical memory left, windoze will automaggicly allocate
more memory by swapping to disk (C:\WINDOWS\WIN386.SWP = Windows' virtual
memory). So, In a Windoze DOS Box you could say you have almost infinite
physical memory (of course it's not really infinite but it's very much!). If
you want to test virtual memory functions in your program you'll have to run
it in plain DOS or disable Virtual Memory in M$ Windoze.

>Rafal
>

Wim Cools
4of10 AT www DOT com


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019