www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/27/02:34:22

Message-ID: <19990927042859.1834.rocketmail@web1401.mail.yahoo.com>
Date: Sun, 26 Sep 1999 21:28:59 -0700 (PDT)
From: Prashant TR <prashant_news AT yahoo DOT com>
Subject: Re: Memory hoarding
To: djgpp AT delorie DOT com
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

Hi Eli,

You asked me for some code to reproduce the malloc
problem. It's here below.

> > I've tried this myself but it hangs because of
> some
> > problem with CWSDPMI (I think). The version of
> CWSDPMI
> > that quake uses doesn't give this problem.
> 
> Please post the shortest test program that exhibits
> this problem.
> 

This is that portion of the code which you asked for.
I have 64MB of RAM here and the program gets *stuck*
at 48MB. I've waited enough, so long that my hard disk
went off to sleep mode.

But there's one thing I have to comment. If I
decreased the memory allocation to 4MB per block, then
it works fine.

You may need to change the declaration of "x" if you
experiment with it.

*****************************************************
int _ctr0_startup_flags = _CRT0_FLAG_LOCK_MEMORY |
_CRT0_FLAG_FILL_SBRK_MEMORY;

int main()
{
 _go32_dpmi_meminfo ret;
 unsigned long maxmem, f, g = 0;
 char *x[64];

 _go32_dpmi_get_free_memory_information(&ret);
 maxmem = ret.total_physical_pages;

 for(f = 0; f < maxmem * 4 * 1024; f += 16 * 1024 *
1024L, g++)
 {
  x[g] = (char *)malloc(16 * 1024 * 1024L);
  if (!x[g]) break;
  printf("%luM memory malloc'd.\n", f / 1024L /
1024L);
  _go32_dpmi_lock_data(x[g], 16 * 1024 * 1024L);
  memset(x[g], 0, 16 * 1024L * 1024L);
 }

 return 0;
}
******************************************************

----
Prashant TR
__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

- Raw text -


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