I have a 1997 BMW M3 and it has 163,000 miles runs great when cold but once it gets to running temp it starts surging idle goes way up then goes down repeatedly till I shut it off once it is shut off it will not start back up till it cools down a few minutes.
I have spent probably 650 dollars on this car and cant afford to spend much more I am a mechanic but this one has me stumped please help me I will donate to this excellent cause around tax time when work picks back up again THANK YOU AND MERRY CHRISTMAS TO YOU AND YOURS!
There is a general Fuel System Management or Igniton system problem.
The air intake tract could be obstructed or clogged. The exhaust tract could be obstructed or clogged. A very common problem on cars with your mileage is the catylitic converter fails inside the exhaust and collapses in on itself which clogs the exhaust. You can try to check this by banging the converter with a rubber mallet or your hand then listen for loose stuff moving around.
The fuel pressure could be low.
You could have a vacuum leak.
There could be a problem with the cranksaft position sensor or the camshaft position sensor which is affecting the timing.
The first thing you should do is to have the trouble codes pulled. Any Advance auto or Auto Zone will do this for free. This will give you a better idea of where to head with diagnosis or it may give you the source of the problem spot on.
Then you need to have the fuel pressure checked. Both the above stores have fuel pressure test kits on a loaner basis. They have adapters to fit the test port on the fuel rail.
I am going to give you a link to a diagnostic walk through that will go over these issues in detail.