What would be the advantage of transferring, say Raticate with 501 CP while already having 100 candies? Is there a limit to the number of times a Pokemon can be powered up?
The only clear advantage would be to get one extra rattata candy, which would only be useful to evolve another Rattata to a Raticate, getting 500 XP in the process.
But if the 501 CP Raticate is one of your most powerful Pokémon, then I would keep it for now to use in gyms.
And yes, there's a limit to how far you can power up any given Pokémon, which is based on your level. Once you hit that limit for a Pokémon, the "power up" button will be faded and disabled. If you level up, however, you can power up each Pokémon 2 more times.
I would transfer it, because as you level up you will naturally find stronger pokemon and the weaker ones will start to take up space. The weaker pokemon will have much less room to improve than a stronger wild/caught pokemon of the same kind. I myself, like to keep one of each pokemon, sometimes two if the pokemon is worth it, such as my two Rhydon, I have 2 because they are both equally strong and they are a good matchup against other pokemon. Plus I can surrender one of them to fight at a gym while my other one is still in my party, but the game is about individuality and personal preference on how you would like to manage your pokemon. That is my advice though, but hey, I am not the all knowing ha.
There is more to it than just CP.
the 500xp you get for an evolution is one of the more reliable ways to gain xp in order to level up and without this it would be almost borderline impossible to ever gain a level (let alone level 40).
Each pokemon has hidden IV stats that make up a pokemons true power potential, which is what the appraise system shows you. So even though it may have high cp, it may have really poor battling ability.
The number of candies you may need to power a pokemon up is quite often more than what you would need if you were to evolve a stronger pre-evolved form, so by transferring, you are providing extra candy towards evolving that pokemon
And yes, there is a limit which is displayed by the half crescent white line which reflects a pokemons maximum level, and its current level (where the white dot is). Each time you power up a pokemon, you increase a pokemons level by 0.5.