I presume you mean the revs are dropping off and it idles at too low RPM (800?) but when you put it in drive it picks up again? It probably a throttle body issue, i would guess. It gets very hot. why it would improve in drive i am not sure thats not really consistent, but throttle body sensors moving when its extremely hot is not unexpected. not sure what you cna do about it!!
has it just started doing this.