Since the attack came as a surprise, the nonessential personnel was still in the city. So hunger played a vital role. I imagine that they managed to ration their food, and possibly obtain more, by growing very limited crops within the walls, and raising the animals rounded up right before the siege. Fear, especially concerning the Nazgul, was a determinant factor. When the Ring was destroyed, the Orcs fled, having lost their driving force.
Every military installation needs support.
I imagine the Architects of Minas Ithil had to take this all into consideration when designing this fortification. Thus, in order to maintain a successful Fortress to guard against onslaught from Mordor, a city must thrive within it. They would be accustomed to the conditions.