Windbg – Iterating through multiple objects

To make your life easier, instead of manually dump every object returned by !dumpheap you can automatize it.

To do that let’s use the token “.foreach” in windbg:

@@.foreach (token {!dumpheap -mt 0f43ad08 -short} ) {!do “token”;!objsize “token”;!gcgen “token”}@@

other possible form of this command although I wouldn’t use it for this case. I write it here as an illustration

@@.foreach /pS 4 /ps 3 (token {!dumpheap -mt 07ab0584} ) {!objsize “token”;!gcgen “token”}@@

Happy debugging!!