Much depends on what size carpeting you have to clean. If you have a building with 24 units in it -all with carpeting, then buy yourself a $2000 portable carpet cleaning machine. You'll probably be running it every few weeks, it'll last you 7 years and will pay for itself....
If you have a house with 4 bedrooms and 1200sqft of carpeting, it might be a toss-up between having it done and renting a machine; depends. A company might charge around $200 to do that - but will do it better than you could with a rental.
If on the other hand you have a 2-bedroom apartment with 300 sqft of carpeting that, by your own admission, is worn, dirty and soon to be replaced, it makes no sense to own a machine like that, or any other one unless you plan on replacing the carpet with more carpet. Here, I'd suggest you have them done for you by a pro. Cost would be around $60 or so, but could depend on a lot of things.
Done once a year by a good carpet cleaner, that'll cost $60. Rent a machine from a supermarket will cost you $35 plus a (lifetime) supply of their chemicals, for another $20 (detergent and defoamers etc).
The rental unit will do a so-so job, the pro will do the best possible...so, where's the savings?