Article View: borland.public.cppbuilder.nativeapi
Article #8605Re: malloc: where is the catch?
From: Azazello
Date: Thu, 07 Oct 2004 18:32
Date: Thu, 07 Oct 2004 18:32
36 lines
2441 bytes
2441 bytes
> Might be interesting to add
>
> GlobalFree( GlobalAlloc( GMEM_FIXED, 0x2000 ) );
> to your tests.
I saw no point in doing it, since GlobalAlloc works like HeapAlloc for
process default heap. I ran it just to double check it and the results are
exactly like HeapAlloc on process default heap. They all go through
ntdll.RtlAllocateHeap.
> (Allocates 81,920,000 bytes)
> char*array[10000];
> void*memory[10000/16];
> for( int i=0; i<10000/16; ++i )
> { memory[i] = GlobalAlloc( GMEM_FIXED,16*0x2000);
> for( int j=0; j<16; ++j )
> array[i*16+j] = (char*)memory[i];
> };
> As i understand it, this is what malloc does, only bigger and more
> complicated.
As I understand memory manager would allocate chunk first and then malloc
would get some pointer from it IF required amount is small enough to be
allocated within commited pages. If we request more than commited, than
malloc will call VirtualAlloc to commit more ( that takes long enough,
longer than pure VirtualAlloc) . That means (note to self), that C RTL heap
does not rely on Win32 heaps and goes for low level virtual function. It
appears to me that initially C RTL memory manager allocates about 1MB.
Thanks, by the way, your reply provoked me to check allocation of large
amounts of memory.
Now, can we get rid of C RTL memory manager altogether, meaning no linking
of cmt3260?
Azazello.
Technical Details
Message-ID:
<41658b84$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4165469c$1@newsgroups.borland.com> <tiqam019j4cp7ud1i2j6s1ef1e04nl6fag@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,50f14b41a5262fc0 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Azazello" <snimi_potniki@hotmail.com> From: "Azazello" <snimi_potniki@hotmail.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <4165469c$1@newsgroups.borland.com> <tiqam019j4cp7ud1i2j6s1ef1e04nl6fag@4ax.com> Subject: Re: malloc: where is the catch? Date: Thu, 7 Oct 2004 11:32:50 -0700 Lines: 38 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 142.58.249.61 Message-ID: <41658b84$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1097173892 142.58.249.61 (7 Oct 2004 11:31:32 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail