The problem is that HeapSetInformation always return FALSE with a
GetLastError = 31 (ERROR_GEN_FAILURE)
the code is simple:
ULONG ulValue=2;
HANDLE hHeap=GetProcessHeap();
BOOL
bOk=::HeapSetInformation(hHeap,HeapCompatibilityInformation,&ulValue,sizeof(
ULONG));
Do you know what i am doing wrong?
Thanks in advance
--
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"WDev" <tp...@hotmail.com> wrote in message
news:lrJN9.85774$qF3.7194@sccrnsc04...
Yes, I test setting the low fragmentation on the default heap outside the
debugger (writing a trace file) and it works. But I also test setting low
fragmention on other heap created by myself (not the default process heap),
and it doesn't work, both within the debugger and outside.
Do you know why this happend?.
"Ivan Brugiolo [MSFT]" <ivan...@online.microsoft.com> escribió en el
mensaje news:efHihh2qCHA.2308@TK2MSFTNGP09...
Can I see the code you use to create the private Heaps ?
I wonder if you are putting some incompatible flags there.
--
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"WDev" <tp...@hotmail.com> wrote in message
news:eq0O9.292514$pN3.22689@sccrnsc03...
Anyway I post you the code below. I create the Heap on a Class (CMemAlloc),
the first method create the heap (retrying with a inferior size if fail),
and the second simply set the Low fragmentation flag (note that both use the
common class data member m_hHeap as heap handle).
//------------------------------------------------------------------
void CMemAlloc::CreateHeap(int iReqSize, bool bThreadSafeMode )
{
DWORD dwFlags;
int iSize=iReqSize;
if( bThreadSafeMode )
dwFlags=0;
else
dwFlags=HEAP_NO_SERIALIZE;
do
{ // keep trying until no error or too litle
m_hHeap = ::HeapCreate( dwFlags, // heap flags (CMemAlloc would also
controls lock serialization)
iSize, // initial size of heap
0); // max heap size
iSize /= 2; // try a smaller request
if( iSize < (int)(m_BlockSize*2) )
{
GLogError4("Fail on create Heap of size %d (Intended %d, BlockSize %d,
bThreadSafeMode %d), using default
heap",iSize*2,iReqSize,m_BlockSize,(int)bThreadSafeMode);
return; // heap would be too small to be usefull, return
// if m_hHeap is ok and even exits here is no problem.
}
}
while( m_hHeap == NULL );
GLogTrace4("Heap created of size %d (Intended %d, BlockSize %d,
bThreadSafeMode %d)",iSize*2,iReqSize,m_BlockSize,(int)bThreadSafeMode);
}
//------------------------------------------------------------------
bool CMemAlloc::SetLowFragmentation()
{
ULONG ulValue=2;
HANDLE hHeap=m_hHeap;
if( hHeap==NULL )
hHeap=GetProcessHeap();
return
::HeapSetInformation(hHeap,HeapCompatibilityInformation,&ulValue,sizeof(ULON
G))==TRUE;
}
"Ivan Brugiolo [MSFT]" <ivan...@online.microsoft.com> escribió en el
mensaje news:esfOy92qCHA.1964@TK2MSFTNGP09...
On the bigger picture, the LowFragHeap is a heap has features such as:
-o- Thread affine allocation in the average case (this guarantees cosistency
with virtual no cost for lock)
-o- Low Fragmentation and almost constant working set for applications with
an istogram
of allocations centered in the low-size part of the graph, and well
contained in the low-size part of the graph.
If you are claiming you known how to lock you heap,
then you are possibly destroying the LowfragHeap heap algorithms,
hence there is no point using them.
Or, in different terms, if you don't need the lock services from the heap,
it means that your application is single threaded anyway,
or you have a per-thread heap with no cross
heap contaminations problem in your code.
Please reflect on the usage of the private heaps, the locking strategy of
the allocator,
the memory graph usage runtime and the frequency of block reuse
before throwing in the LowFrag heap.
--
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"WDev" <tp...@hotmail.com> wrote in message
news:0W0O9.492640$QZ.74249@sccrnsc02...
Thanks for the information anyway. Do you know where I could find extended
information about the Low Frag Heap?, since I didn't find in the
documentation information like you just had given to me.
"Ivan Brugiolo [MSFT]" <ivan...@online.microsoft.com> escribió en el
mensaje news:eERSue3qCHA.2304@TK2MSFTNGP12...