Engine revving

I have a 2004 Hyndai Elantra with about 103,000 miles on it. I notice that after I drive it for a couple of hours with a/c on the enigne revves while I have the brake on or while I am in park. What causes that and expensive to fix? It dosent happen all the time but it is weird when it dose.

My guess is a sticky idle air control valve. It might take no more then having the valve and the throttle body cleaned.