Relationship between Windbg !heap and HeapCreate

Hi,

I've wrote a test application which creates numerous heaps via HeapAlloc. However, when I attach and run the !heap command in WinDbg I only see a single (presumably default) heap.

If i force NT / Segment heap on the process this is correctly reflected in !heap, but I only ever see one entry.

What am I missing?
Jason

Oh, I forgot to mention that when I Walk the heap using win32 HeapWalk calls I can see many heaps as expected

Jason

HeapAlloc does not create a heap. It allocates memory from an existing heap.

Sorry, it's been a long day. I mistyped my original post. I should have typed:
I've wrote a test application which creates numerous heaps via **HeapCreate**.

I would have thought 1x HeapCreate = 1 more visible heap in !heap?

Jason

yes 1 HeapCreate() should show 1 more Heap entry in !heap command

#include <windows.h>
#include <stdio.h>
#define MyHeapNum 0x80
int main (void) 
{
	HANDLE MyHeaps[MyHeapNum] = {0};
	for (int i =0; i<MyHeapNum; i++ )
	{
		MyHeaps[i] =  HeapCreate(0,0,0);
		printf("%p\n" , MyHeaps[i]);
	}
}

toss the compiled exe into cdb
disassemble main and locate the address after the HeapCreate Call
set a breakpoint on the address and check the default heaps before continuing

0:000> bl
 0 e 00007ff6`30341057     0001 (0001)  0:**** heapy!main+0x57
0:000> ub 00007ff6`30341057 l1
heapy!main+0x51:
00007ff6`30341051 ff15a9cf0400    call    qword ptr [heapy!_imp_HeapCreate (00007ff6`3038e000)]
0:000> !heap
        Heap Address      NT/Segment Heap

         24106630000              NT Heap
         241065b0000              NT Heap

continue with g;!heap each continuation should yield one extra entry

0:000> g;!heap
Breakpoint 0 hit
        Heap Address      NT/Segment Heap

         24106630000              NT Heap
         241065b0000              NT Heap
         24106920000              NT Heap
0:000> g;!heap
0000024106920000
Breakpoint 0 hit
        Heap Address      NT/Segment Heap

         24106630000              NT Heap
         241065b0000              NT Heap
         24106920000              NT Heap
         24106a50000              NT Heap
0:000> g;!heap
0000024106A50000
Breakpoint 0 hit
        Heap Address      NT/Segment Heap

         24106630000              NT Heap
         241065b0000              NT Heap
         24106920000              NT Heap
         24106a50000              NT Heap
         24106c50000              NT Heap
0:000> g;!heap
0000024106C50000
Breakpoint 0 hit
        Heap Address      NT/Segment Heap

         24106630000              NT Heap
         241065b0000              NT Heap
         24106920000              NT Heap
         24106a50000              NT Heap
         24106c50000              NT Heap
         24106c20000              NT Heap
0:000> g;!heap
0000024106C20000
Breakpoint 0 hit
        Heap Address      NT/Segment Heap

         24106630000              NT Heap
         241065b0000              NT Heap
         24106920000              NT Heap
         24106a50000              NT Heap
         24106c50000              NT Heap
         24106c20000              NT Heap
         241068c0000              NT Heap
0:000>

executing 0n127 times

0:000> g;!heap;dv
0000024106B50000 <<<<<<<<<<<<<<<<<
Breakpoint 0 hit
        Heap Address      NT/Segment Heap

         24106630000              NT Heap
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
         24108000000              NT Heap
              i = 0n127
        MyHeaps = void *[128]

0:000> dt -a MyHeaps
Local var @ 0xe649f5f700 Type void*[]
[0] @ 000000e6`49f5f700
---------------------------------------------
0x00000241`06920000
Void
xxxxxxxxxxxxxxxxxxxxxxxxx
[126] @ 000000e6`49f5faf0 <<<<<<<<<<<<<<<<<
---------------------------------------------
0x00000241`06b50000 <<<<<<<<<<<<<<<<<<<<<<
Void
[127] @ 000000e6`49f5faf8
---------------------------------------------
(null)

Yea, !heap is not showing any additional heaps for me with your sample. Perhaps because i'm on a VM... /shrug

i am using the latest windbg / windbgx / cdb
for me the classic windbg does not output dml
while windbgx outputs dml

while in your case the classic windbg seems to output dml from your screen shot
may be check and update windbg version if need be ?

classic windbg no dml

windbgx dml output