www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/06/13/23:34:56

From: Ron Grunwald <RGRUNWAL AT wasp DOT cs DOT cowan DOT edu DOT au>
Organization: Edith Cowan University
To: kagel AT ts1 DOT bloomberg DOT com
Date: Wed, 14 Jun 1995 09:40:28 GMT+800
Subject: Re: Malloc without malice 2
Reply-To: r DOT grunwald AT cowan DOT edu DOT au
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu

Art S. Kagel wrote:

> I have a sort program I ported to DJGPP which malloc() and free()s all over the
> place and it has never failed.  I have sorted files of several hundred thousand
> records which translates to over 1/2 million malloc()s and matching free()s.
> 

Doing around 1/2 million function calls to malloc(), isn't that a bit 
inefficient, considering the enourmous execution thread the system 
has to follow to allocate a single block of memory?

Using the stack might be a much faster method as you only need 3 
assembly language instructions for the same task.

Eg.

        push   ebp
        mov    ebp,esp
        sub    ebp,BLOCKSZ


Regards, Ron.

 

 ********************************************************************
 | Author.............. Ron Grunwald                                | 
 | Internet............ r DOT grunwald AT cowan DOT edu DOT au                     |
 | Phone............... (09)273 8027 or (09)273 8468                |
 |------------------------------------------------------------------|
 | Department.......... Computer Operations and Systems Management  |
 | Division/Faculty.... Information Technology                      | 
 | Institute........... Edith Cowan University, Churchlands         | 
 | Location............ Perth, Western Australia                    |
 ********************************************************************
 "I don't have any solution but I certainly admire the problem!"


- Raw text -


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