delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/01/04/04:09:07

Date: Tue, 4 Jan 94 09:38:09 +0100
From: vincent AT physique DOT ens DOT fr
To: djgpp AT sun DOT soe DOT clarkson DOT edu

	Among the samples coming with DJGPP 1.11 I found a packdrv.c
	with which network package does it work ?
	
	I am having a serious pb with freeing memory which is
	apparently never freed : using a sligtly modified dpmimem.c 
	here is what I get ! Am I making a stupid mistake or how can
	I get back my memeory ?


available memory          =      22,257,664
available pages           =           5,434
available lockable pages  =           1,851
linear space              =              -1
unlocked pages            =           1,864
available physical memory =       7,581,696
total physical memory     =       7,634,944
free linear space         =              -1
size of paging file       =      14,675,968
remaining physical memory =       7,581,696
remaining virtual memory  =      22,257,664

memory alloced and freed
%	this is the piece of code I mean by that 
%	c = (char *)calloc(4*1024*1024,sizeof(char));
%	if (c == NULL)	
%	{
%		fprintf(stderr,"calloc error\n");
%		exit(0);
%	}
—	free(c);
%

available memory          =      18,051,072
available pages           =           4,407
available lockable pages  =             824
linear space              =              -1
unlocked pages            =           1,864
available physical memory =       3,375,104
total physical memory     =       7,634,944
free linear space         =              -1
size of paging file       =      14,675,968
remaining physical memory =       3,375,104
remaining virtual memory  =      18,051,072

	many thanks for any clue
	
	vincent croquette, here follow the modified program


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

char *comma(u_long val)
{
  static char buf2[30];
  char buf1[30];
  int i, j;
  sprintf(buf1, "%12d", val);
  for (j=0, i=0; i<12; i++)
  {
    buf2[j] = buf1[i];
    j++;
    if (i == 11)
      break;
    if (i%3 == 2)
    {
      if (buf1[i] != ' ')
        buf2[j++] = ',';
      else
        buf2[j++] = ' ';
    }
  }
  buf2[j++] = 0;
  return buf2;
}

int main()
{
  int i, pm, vm;
  _go32_dpmi_meminfo meminfo;
	char *c;

  pm = _go32_dpmi_remaining_physical_memory();
  vm = _go32_dpmi_remaining_virtual_memory();
  _go32_dpmi_get_free_memory_information(&meminfo);

  printf("available memory          = %s\n", comma(meminfo.available_memory));
  printf("available pages           = %s\n", comma(meminfo.available_pages));
  printf("available lockable pages  = %s\n", comma(meminfo.available_lockable_pages));
  printf("linear space              = %s\n", comma(meminfo.linear_space));
  printf("unlocked pages            = %s\n", comma(meminfo.unlocked_pages));
  printf("available physical memory = %s\n", comma(meminfo.available_physical_pages * 4096));
  printf("total physical memory     = %s\n", comma(meminfo.total_physical_pages * 4096));
  printf("free linear space         = %s\n", comma(meminfo.free_linear_space));
  printf("size of paging file       = %s\n", comma(meminfo.max_pages_in_paging_file * 4096));
  printf("remaining physical memory = %s\n", comma(pm));
  printf("remaining virtual memory  = %s\n", comma(vm));
  

	c = (char *)calloc(4*1024*1024,sizeof(char));
	if (c == NULL)	
	{
		fprintf(stderr,"calloc error\n");
		exit(0);
	}
	free(c);
	
	printf("memory alloced and freed \n");
	
  pm = _go32_dpmi_remaining_physical_memory();
  vm = _go32_dpmi_remaining_virtual_memory();
  _go32_dpmi_get_free_memory_information(&meminfo);

  printf("available memory          = %s\n", comma(meminfo.available_memory));
  printf("available pages           = %s\n", comma(meminfo.available_pages));
  printf("available lockable pages  = %s\n", comma(meminfo.available_lockable_pages));
  printf("linear space              = %s\n", comma(meminfo.linear_space));
  printf("unlocked pages            = %s\n", comma(meminfo.unlocked_pages));
  printf("available physical memory = %s\n", comma(meminfo.available_physical_pages * 4096));
  printf("total physical memory     = %s\n", comma(meminfo.total_physical_pages * 4096));
  printf("free linear space         = %s\n", comma(meminfo.free_linear_space));
  printf("size of paging file       = %s\n", comma(meminfo.max_pages_in_paging_file * 4096));
  printf("remaining physical memory = %s\n", comma(pm));
  printf("remaining virtual memory  = %s\n", comma(vm));
  	

  return 0;
}



- Raw text -


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