www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/08/28/20:16:59

Date: Tue, 29 Aug 1995 01:33:58 +0200 (MET DST)
From: Davide Rossi <rossi AT cs DOT unibo DOT it>
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: v2 memory crazyness

Hey guys,
this really looks like a big bug somewhere: compile the following code and
you'll se how v2 eats memory. Nope, it is not a malloc trouble: you can
obtain the same using new/delete.
What's worse the memory get lost only when referenced: strip out the zepo
padding code and no more trouble with that...
Hey guys: this think drove me crazy (you know what you mean: hey, I was sure
I freed all the pointers... ;).
Of course it could even be a cwsdpmi trouble...

Ciao,
	Davide.

PS: It's quite a lot I don't receive any message: who the hell kicked me off
the list? Should I re-subscribe?

----8<----8<-----
#include <stdlib.h>
#include <stdio.h>
#include <dpmi.h>
#include <go32.h>

#define SIZE 1024*256

int
main()
{
  for(int i=SIZE; i<4*1024*1024; i+=SIZE) {
    char *ptr=(char *)malloc(i);
    if(!ptr) {
      exit(1);
    }
    for(int j=0; j<i; j++) {
      *(ptr+j)=0;
    }
    _go32_dpmi_meminfo info;
    _go32_dpmi_get_free_memory_information(&info);
    printf("%d %d\n", info.available_memory,
	info.available_physical_pages*4096);
    free(ptr);
  }
}

- Raw text -


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