Discussion:
Low-Fragmentation Heap
(too old to reply)
Ralf Tobel
2005-10-26 16:15:11 UTC
Permalink
Hello,

I'm desperatly trying to switch on the low-fragmentation heap for the crt
heap in C++ in VS.NET 2003 on a Windows XP SP2 machine with the following
code:

ULONG HeapFragValue = 2;
int ret = HeapSetInformation((HANDLE)_get_heap_handle(),
HeapCompatibilityInformation, &HeapFragValue, sizeof(HeapFragValue));

It always returns 0 which means according to the documentation that it
didn't succeeded.

So I tried to create a new heap to test if it's a problem with the crt heap:

HANDLE hh = HeapCreate(0, 0, 0);
ULONG HeapFragValue = 2;
int ret = HeapSetInformation(hh, HeapCompatibilityInformation,
&HeapFragValue, sizeof(HeapFragValue));

This also returns 0.

So what's the trick?

Any hints are welcome.

Ralf
Patrice
2005-10-26 17:15:06 UTC
Permalink
Have you tried to use GetLastError and/or to see if HeapCreate fails for the
second one ?
(and I would try rather a group such as
microsoft.public.dotnet.languages.vc).
--
Patrice
Post by Ralf Tobel
Hello,
I'm desperatly trying to switch on the low-fragmentation heap for the crt
heap in C++ in VS.NET 2003 on a Windows XP SP2 machine with the following
ULONG HeapFragValue = 2;
int ret = HeapSetInformation((HANDLE)_get_heap_handle(),
HeapCompatibilityInformation, &HeapFragValue, sizeof(HeapFragValue));
It always returns 0 which means according to the documentation that it
didn't succeeded.
HANDLE hh = HeapCreate(0, 0, 0);
ULONG HeapFragValue = 2;
int ret = HeapSetInformation(hh, HeapCompatibilityInformation,
&HeapFragValue, sizeof(HeapFragValue));
This also returns 0.
So what's the trick?
Any hints are welcome.
Ralf
Ralf Tobel
2005-10-26 19:01:06 UTC
Permalink
Post by Patrice
Have you tried to use GetLastError and/or to see if HeapCreate fails for the
second one ?
HeapCreate succeeds and the error code for HeapSetInformation is 31: A
device attached to the system is not functioning.
Post by Patrice
(and I would try rather a group such as
microsoft.public.dotnet.languages.vc).
Good idea. Thanks.
Ralf Tobel
2005-10-27 12:10:24 UTC
Permalink
Problem solved.

It only doesn't work if you start the application inside the debugger.

Ralf
ch0kee
2010-03-06 07:01:54 UTC
Permalink
If you want to use LFH in debug, add (or set, if exists) _NO_DEBUG_HEAP environment variable (plain windows environment variable) with value 1
_NO_DEBUG_HEAP = 1

From http://www.developmentnow.com/g/54_2005_10_0_0_624698/Low-Fragmentation-Heap.ht

Posted via DevelopmentNow.com Group
http://www.developmentnow.com/g/

Loading...