Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use windbg track memory allocated with VirtualAlloc?

you know how you can use gflags wih +ust to get the call stack paired with each allocation. you can then use !heap in windbg to diagnose leaks?

I want to do this with large allocations made through VirtualAlloc. As far as I can tell VirtualAlloc bypasses the gflags/!heap extensions?

I'm hoping someone can confirm

a) !heap walks the list of allocated memory in each heap - but not the allocated memory that came from VirtualAlloc

b) when you allocate a huge chunk of memory via new/malloc that goes to LocalAlloc() and then to VirtualAlloc() where it bypasses the call stack logging

I'm really hoping someone can assist me in debugging this sort of leak. if the allocations were smaller I'd have no trouble with !heap

like image 468
stuck Avatar asked May 14 '11 23:05

stuck


2 Answers

You can try LeakDiag which works on a number of different types of memory including memory originiating from VirtualAlloc.

like image 118
Mario Hewardt Avatar answered Sep 20 '22 22:09

Mario Hewardt


The heap functions operate at a higher level than the Virtual* functions; in fact, the heap must call VirtualAlloc to add more memory to the process address space. !heap isn't going to help you with Virtual* calls.

like image 24
Aaron Klotz Avatar answered Sep 18 '22 22:09

Aaron Klotz