🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #8597

Re: malloc: where is the catch?

#8597
From: Ed Mulroy [TeamB]
Date: Thu, 07 Oct 2004 15:09
40 lines
2677 bytes
Windows has limits on the number of handles it will provide and 
Windows allocation/deallocation calls are slow.

The runtime library memory allocation functions encapsulate Windows 
allocation calls, allocating a chunk when called, dolling out a piece 
of that block of  the requested size to you and leaving the rest as 
available for subsequent calls.  Later when free is called, the freed 
block will most likely to be made available for future allocation 
calls instead of being given back to the operating system.

.  Ed

> Azazello wrote in message
> news:4165469c$1@newsgroups.borland.com...
>
> Hi there,
>
> Haven't been here for a while, glad to see that TeamB is still
> active. You guys rock! ;)
>
> Now to the topic. I've been playing with multithreading under
> Win32 and as a part of it ran into a question about optimal
> memory allocation, which provoked me to test speed of
> different memory allocation functions. The results were,
> should I say, interesting, and though most of you ran these
> tests yourself, I'll take the liberty to share them.
>
> Setup: 10000 cycles of allocation/deallocations of
> 0x2000 bytes (8K) ; Performance Counter used as timer.
> ...
> 1. Can someone explain to me how malloc (serialized
> function, by the way) can be 33 (SIC!) times faster than
> heap functions and 11 times faster than VirtualAlloc (ok,
> VirtualAlloc zeros memory, but still, calloc is 2 times
> faster)?
> 2. Why Non-serialized/non-growable heap is twice slower
> than serialized/growable heap? Shouldn't it be other way
> around?
> 3. malloc seems to be too good to be true, so where is the
> catch? What does not malloc do compare to other functions?
Technical Details
Message-ID: <41655c2d@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4165469c$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,50f14b41a5262fc0
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Ed Mulroy [TeamB]" <dont_email_me@invalid.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4165469c$1@newsgroups.borland.com>
Subject: Re: malloc: where is the catch?
Date: Thu, 7 Oct 2004 11:09:27 -0400
Lines: 42
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
NNTP-Posting-Host: 12.161.27.84
Message-ID: <41655c2d@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1097161773 12.161.27.84 (7 Oct 2004 08:09:33 -0700)
X-Authenticated-User: edmulroy
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail