delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/30/23:46:54

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: _fmalloc() equivalent in djgpp
Date: Fri, 30 Jan 1998 19:05:32 -0500
Organization: Two pounds of chaos and a pinch of salt.
Lines: 46
Message-ID: <34D26ACC.7B9D@cs.com>
References: <34D22AB4 DOT 3991C754 AT tp DOT silkera DOT net>
NNTP-Posting-Host: ppp237.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Liche wrote:
> 
> Is there a need for the equivalent of _fmalloc() in djgpp?  I assume no,
> because there are no 64k segment restrictions (just learned that a day
> ago ;-).  Does that mean malloc() will allocate memory dynamically from
> all of the available ram on my machine?  Or are there other restrictions
> that limit the size of memory I can allocate dynamically with malloc()?
> What about new?  And if my first assumption is incorrect, what is the
> _fmalloc() equivalent in djgpp?  Thanks

Your first assumption is correct:  when allocating memory for your
program's internal use, there is no need for any kind of special
function to overcome the 64 Kb segment limitation.  You have a 32 bit
address space, so the (theoretical) maximum amount of memory you can
allocate at any one time is 4 gigabytes.

That said, the actual maximum amount depends on a number of factors. 
First, the standard malloc() library routine rounds all memory requests
up to the nearest power of two (so 100 Kb would become 128 Kb; 5 Mb
would become 8 Mb, etc.).  This increases speed but reduces efficiency. 
Second, the actual amount of memory available depends on your DPMI
host.  The latest version of CWSDPMI (the DOS DPMI host that comes with
DJGPP) lets you use up to 256 Mb of RAM and 256 Mb of hard drive space
for a total of 512 Mb of virtual memory.  Windows 3.1 and Windows 95 (*)
only allow 64 Mb of total virtual memory for any single DOS program, and
you may only request half of that in any single block.  Other DPMI hosts
(Linux, Windows NT, OS/2, etc.) have their own restrictions.

(*) To increase Windows 95's DPMI memory allocation, edit the MS-DOS
prompt properties sheet.  The list box for DPMI memory only shows up to
16346 Kb, but you can manually enter a value up to 65535 Kb.

When handling memory outside your program's address space (DOS memory,
video memory, etc.), totally different rules apply.  That's where the
FAQ comes in, primarily in chapter 18.  It's a good document for all
DJGPP users to read at least once.

hth!

-- 
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I  |     mailto:fighteer AT cs DOT com     |
| "Starting flamewars since 1993"  |   http://www.cs.com/fighteer/  |
|  *** NOTICE ***  This .signature |       ICQ UIN#:  7406319       |
|  is generated randomly.  If you don't like it, sue my computer.   |
---------------------------------------------------------------------

- Raw text -


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