Search EggHeadCafe's Job Board
EggHeadCafe Silverlight WPF ASP.NET VB.NET C# Excel SQL Server SharePoint
search
.NET Framework GroupsView
.NET Distributed_Apps
.NET
.NET ADO.NET
.NET ASP.NET
.NET ASP.NET Security
.NET ASP.NET Webcontrols
.NET ASP.NET Web Services
.NET Clr
.NET Compact Framework
.NET Drawing
.NET Interop
.NET Performance
.NET Web Services
.NET Windows Forms
.NET Windows Forms Controls
.NET General
.NET Csharp
.NET Visual Basic
.NET Vc
.NET Security
.NET Xml
Vsnet Debugging
Xml
Xsl
Scripting Jscript
Scripting Visual Basicscript
Scripting Wsh
Smartphone Developer
Visual Basic Com
Visual Basic Controls
Visual Basic Crystal
Visual Basic Database Ado
Visual Basic Syntax
Visual Basic Winapi
Vc Atl
Vc Debugger
Vc Language
Vc Mfc
Vc Stl
Visio Developer Visual Basica
Windowsce Embedded Vc
Windows Powershell
Visual Basic Vista Compatibility
Deployment Server
.NET Micro Porting

Group SummariesView
.NET Framework
Access
BizTalk
Certifications
CRM
DDK
Exchange Server
FoxPro
French
French .NET
Games
German
German .NET
Graphic Design
IIS
Internet
ISA Server
Italian
Italian .NET
Maps
MCIS
Miscellaneous
Mobile Apps
Money
MSN
Networking
Office
Ops Mgr
Publisher
Security
SharePoint
Small Business
Spanish
Spanish .NET
SQL Server
Systems Management Server
Transaction Server
Virtual PC / Virtual Server
Visual Studio
Win32
Windows 2000
Windows 2003 Server
Windows 7
Windows Live
Windows Media
Windows Update
Windows Vista
Windows XP
 

View All Microsoft Vc Language Posts  Ask A New Question 

setting LFH (low fragmentation heap) on handles returned by getprocessheaps()

Alex Blekhman posted on Friday, February 15, 2008 5:18 PM

I don't know what are these heaps, but heaps don't have names,
AFAIK.


The one with the handle equal to the value returned by
`_get_heap_handle' CRT function.


Probably it has some features incopatible with LFH. For example,
it could be created with `HEAP_NO_SERIALIZE' flag, as mentioned in
MSDN.

Alex
reply

 

setting LFH (low fragmentation heap) on handles returned by getprocessheaps()

ted posted on Saturday, February 16, 2008 4:49 AM

I'm running this simple C program (see below, compiled with cl.exe
version 14.00, XP SP2) and see the following  output:

Number of heaps returned by GetProcessHeaps() = 4
Heap 0: Succeeded (1) setting LFH
Heap 1: Succeeded (1) setting LFH
Heap 2: Failed (0) setting LFH, error = 31
Heap 3: Succeeded (1) setting LFH

Q: What are these 4 heaps? Do they have names (and how can I get the
names)?

Q: Which one corresponds to the one used by malloc()?

Q: Why does Heap 2 fail?



int main()
{
HANDLE aHeap[101] ;
ULONG HeapFragValue = 2 ;
BOOL retval ;
DWORD ii, nHeaps ;

nHeaps =(int)GetProcessHeaps( 100, aHeap ) ;     printf( "\nNumber
of heaps returned by GetProcessHeaps() = %d", nHeaps ) ;
for ( ii = 0 ; ii < nHeaps ; ii++ )
{
retval = HeapSetInformation( aHeap[ii],
HeapCompatibilityInformation,
&HeapFragValue,
sizeof(HeapFragValue) ) ;
if ( retval != 0 )
{
printf( "\nHeap %d: Succeeded (%d) setting LFH",
ii, retval ) ;
}
else
{
printf( "\nHeap %d: Failed (%d) setting LFH, error
= %d", ii, retval, GetLastError() ) ;
}
}

return 0 ;
}
reply

setting LFH (low fragmentation heap) on handles returned by getprocessheaps()

Alex Blekhman posted on Saturday, February 16, 2008 1:32 PM

This is incorrect. HeapInformation = 0 does not automatically mean
that the heap is used by CRT. You should get CRT heap's handle by
calling `_get_heap_handle'.

Alex
reply

setting LFH (low fragmentation heap) on handles returned by getprocessheaps()

Alex Blekhman posted on Sunday, February 17, 2008 7:01 AM

Actually, I don't know whether there exists "standard" heap at
all. I think that CRT is free to choose a heap to use or to create
its own. I tried the code form this post:

http://groups.google.com/group/microsoft.public.win32.programmer.kernel/msg/b290154476a4425c

It reveals that there are at least two heaps with HeapInformation
= 0. One of them is indeed CRT heap.


I can't neither confirm nor refute that since I never heard about
this requirement. I always thought that CRT can use any heap it
sees fit.

Alex
reply

setting LFH (low fragmentation heap) on handles returned by getprocessheaps()

Abhishek Padmanabh posted on Sunday, February 17, 2008 10:19 AM

HeapQueryInformation gives info about what the specific heap is. See
here - http://msdn2.microsoft.com/en-us/library/aa366703(VS.85).aspx
HeapInformation could be 0, 1 or 2. See details at the above page.


The standard heap (for which HeapInformation is 0) would be the one
where from you get the allocations, but I believe it depends on the
runtime to decide which one would be better from performance point of
view but I am sure of this. To allocate from specific heaps you would
make calls to HeapAlloc (and functions of that family).



To understand why heap 2 failed to set up as LFH, you would need to
know what heap that is and if setting it as LFH makes sense.
reply

setting LFH (low fragmentation heap) on handles returned by getprocessheaps()

Abhishek Padmanabh posted on Sunday, February 17, 2008 10:20 AM

Actually, I missed a "not" before sure. :) Thanks for correcting me.
But, isn't the standard heap the one from which the allocations would
be done? I mean, one could change the heap info of standard heap to an
LFH but unless that is done, _get_heap_handle should return the same
heap as GetProcessHeap and that would be the same as the heap with HI
as 0 returned from GetProcessHeaps (considering heap info has not been
played around with). No?
reply