Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Problem while setting Low Fragmentation Heap
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
WDev  
View profile  
 More options Dec 23 2002, 2:26 pm
Newsgroups: microsoft.public.win32.programmer.kernel
From: "WDev" <t...@hotmail.com>
Date: Mon, 23 Dec 2002 19:26:09 GMT
Local: Mon, Dec 23 2002 2:26 pm
Subject: Problem while setting Low Fragmentation Heap
I am trying to use the Low Fragmentation Heap on the default heap on a XP
platform.

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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ivan Brugiolo [MSFT]  
View profile  
 More options Dec 24 2002, 11:27 am
Newsgroups: microsoft.public.win32.programmer.kernel
From: "Ivan Brugiolo [MSFT]" <ivanb...@online.microsoft.com>
Date: Tue, 24 Dec 2002 08:20:41 -0800
Local: Tues, Dec 24 2002 11:20 am
Subject: Re: Problem while setting Low Fragmentation Heap
Does it happen when you running the process under debugger or all the times
?

--
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" <t...@hotmail.com> wrote in message

news:lrJN9.85774$qF3.7194@sccrnsc04...
> I am trying to use the Low Fragmentation Heap on the default heap on a XP
> platform.

> 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 (


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
WDev  
View profile  
 More options Dec 24 2002, 12:02 pm
Newsgroups: microsoft.public.win32.programmer.kernel
From: "WDev" <t...@hotmail.com>
Date: Tue, 24 Dec 2002 17:02:02 GMT
Local: Tues, Dec 24 2002 12:02 pm
Subject: Re: Problem while setting Low Fragmentation Heap
It seems extrange:

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]" <ivanb...@online.microsoft.com> escribió en el
mensaje news:efHihh2qCHA.2308@TK2MSFTNGP09...

bOk=::HeapSetInformation(hHeap,HeapCompatibilityInformation,&ulValue,sizeof (


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ivan Brugiolo [MSFT]  
View profile  
 More options Dec 24 2002, 12:12 pm
Newsgroups: microsoft.public.win32.programmer.kernel
From: "Ivan Brugiolo [MSFT]" <ivanb...@online.microsoft.com>
Date: Tue, 24 Dec 2002 09:11:16 -0800
Local: Tues, Dec 24 2002 12:11 pm
Subject: Re: Problem while setting Low Fragmentation Heap
The debugger enable certain flags on all the heaps, so that certain common
problems can be caught.
The LowFrag Heap is a piece of code really hard to debug when you have
corruptions and/or double
free and or reuser-after-delete, while the regular heap is somehow more
resistent to these problems.
(is you have a heap corruption on the regular heap there are 20%-30% chances
to find the culprit
by analysis on the stack and the heap, while with LowFrag the chances are
near zero,
that's why its not recomended for debug purposes).

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" <t...@hotmail.com> wrote in message

news:eq0O9.292514$pN3.22689@sccrnsc03...

bOk=::HeapSetInformation(hHeap,HeapCompatibilityInformation,&ulValue,sizeof (


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
WDev  
View profile  
 More options Dec 24 2002, 12:36 pm
Newsgroups: microsoft.public.win32.programmer.kernel
From: "WDev" <t...@hotmail.com>
Date: Tue, 24 Dec 2002 17:35:56 GMT
Local: Tues, Dec 24 2002 12:35 pm
Subject: Re: Problem while setting Low Fragmentation Heap
The flag that I am using when creating the particular heap is
HEAP_NO_SERIALIZE. Do you know if that could cause the fail?, do you know
why?. Thanks for your answers.

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(ULO N
G))==TRUE;

}

"Ivan Brugiolo [MSFT]" <ivanb...@online.microsoft.com> escribió en el
mensaje news:esfOy92qCHA.1964@TK2MSFTNGP09...

bOk=::HeapSetInformation(hHeap,HeapCompatibilityInformation,&ulValue,sizeof (


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ivan Brugiolo [MSFT]  
View profile  
 More options Dec 24 2002, 1:18 pm
Newsgroups: microsoft.public.win32.programmer.kernel
From: "Ivan Brugiolo [MSFT]" <ivanb...@online.microsoft.com>
Date: Tue, 24 Dec 2002 10:10:12 -0800
Local: Tues, Dec 24 2002 1:10 pm
Subject: Re: Problem while setting Low Fragmentation Heap
If you are choosing no serialization, then you don't need the LowFragHeap.
So, your actual problem is that flag.

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" <t...@hotmail.com> wrote in message

news:0W0O9.492640$QZ.74249@sccrnsc02...

::HeapSetInformation(hHeap,HeapCompatibilityInformation,&ulValue,sizeof(ULO N

bOk=::HeapSetInformation(hHeap,HeapCompatibilityInformation,&ulValue,sizeof (


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
WDev  
View profile  
 More options Dec 24 2002, 3:09 pm
Newsgroups: microsoft.public.win32.programmer.kernel
From: "WDev" <t...@hotmail.com>
Date: Tue, 24 Dec 2002 20:09:35 GMT
Local: Tues, Dec 24 2002 3:09 pm
Subject: Re: Problem while setting Low Fragmentation Heap
Well, that the case: I have a per-thread exclusive heap, that is because a
use the HEAP_NO_SERIALIZE on it (there isn't needed any locking).
Additionaly that heap it used normally for smalls allocations (< 16k), with
a high reuse rate(frecuent "frees" and new allocations), so that is the
reason because I want to use the Low Fragmentation Heap. I still think it
would be usefull for that (based on your second named feature).

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]" <ivanb...@online.microsoft.com> escribió en el
mensaje news:eERSue3qCHA.2304@TK2MSFTNGP12...

::HeapSetInformation(hHeap,HeapCompatibilityInformation,&ulValue,sizeof(ULO N

bOk=::HeapSetInformation(hHeap,HeapCompatibilityInformation,&ulValue,sizeof (


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google