If you push/pop an element in a loop 1 million times, nodes will be empty, but node_map will have length 1 million. It is never emptied. I think there could be better design using a circular buffer that would only ever require node_map to be as long as the maximum size of the heap?