Whitehack provides my favorite answer to this question. Casting normal magic costs hitpoints. They heal. The crafting of magic items costs permanent hit points. They do not heal. But in that game, you reroll your HP every time you level (and only take the new value if it's greater).
This provides a per-level limitation which doesn't have the same mechanical profile as XP cost but it's similar and elegant enough that you might want to adopt it for another game.
ETA: It totally makes sense then, that a wise character (that is, one who has access to "miracles" (magic)) engaged in crafting items will attempt to actually create these items as she nears a level-up. Whether that character is then able to level up risk-free once their HP are depleted is a matter of luck and the GM's skill and agenda. I don't think this is likely to be a significant exploit because it has an "old-school" (I have qualms with using this term, but if you read generously I think we'll all be on the same page) ethos that I think bears on this issue in two way. First, if the players are crafty about manipulating the universe, then they deserve to reap benefits. Second, killing "monsters" produces a relatively minor portion of the XP that characters collect. Treasure looted from dungeons is the largest portion while "mission" rewards and vanquishing monsters each make up relatively small chunks. The GM has tremendous power in implementation though, so it's largely up to their preference and skill and the table's mode of operation. To provide a reliable risk-free source of rats (or similar xp-fountain) would, I think, be sloppy use of the game, under most circumstances.