module Process

def get_heap_info(handle)

Return heap info for Process.snapshot
def get_heap_info(handle)
  hash = Hash.new { |h, k| h[k] = [] }
  hl = HEAPLIST32.new
  hl[:dwSize] = hl.size
  if Heap32ListFirst(handle, hl)
    while Heap32ListNext(handle, hl)
      he = HEAPENTRY32.new
      he[:dwSize] = he.size
      if Heap32First(he, Process.pid, hl[:th32HeapID])
        hash[he[:th32ProcessID]] << HeapSnapInfo.new(he[:dwAddress], he[:dwBlockSize], he[:dwFlags], he[:th32ProcessID], he[:th32HeapID])
      else
        if FFI.errno == ERROR_NO_MORE_FILES
          break
        else
          raise SystemCallError.new("Heap32First", FFI.errno)
        end
      end
      hash[he[:th32ProcessID]] << HeapSnapInfo.new(he[:dwAddress], he[:dwBlockSize], he[:dwFlags], he[:th32ProcessID], he[:th32HeapID]) while Heap32Next(he)
    end
  end
  hash
end