Let’s say that early middle ages humans discovered and expanded into a newly discovered land. Those humans made a concentrated effort to populate this new territory; they shipped several ships of settlers and refugees, along with armies of soldiers intended to forge a foothold. Then flashforward a hundred years.
Despite the human’s best efforts, they proved incapable of fully conquering this new world. Many of the native creatures – mostly roving monsters or scattered primitive warbands – simply proved too formidable to be hunted, repelled or defeated.
The humans did manage to establish several coastal colonies in the new world – yet their cities rely entirely on strong walls to keep the natives out and protect the citizens. Outside of these scattered few fortified human cities, the land is still wilderness ruled by monsters. Even travelling alone is a coin-flip. Unlike in the real-world, humans here are not the top of the food chain.
As a result, for settlers farming or homesteading is very difficult: if a family of farmers ever tries to set up a farm outside of the walls, they get eaten by the natives very quickly. Claiming new territory not impossible, but it requires a dedicated force of soldiers to hold the perimeter. The humans could fortify a farm, but there’s a limit on how many walls they can build or how many soldiers they can spare to hold them.
As such, growing crops is treacherous work; supplies are limited, people are hunted, and establishing secure farmland usually requires more manpower than it can feed. Assume that the humans are stretched to their limit.
Humans can still leave their walls to hunt or fish the smaller native animals – yet hunting is perilous due to the big creatures around. The ecosystem is mostly comparable to the real world examples, but with the addition of predatory megafauna. Some of these large predators can fly, others hunt by sea, and many are just hordes of monsters.
The question is; is this situation actually sustainable?
Generally, cities consume far more than they produce. In early civilizations, most of the populace rely on single-family farms or homesteading. Hunting and foraging is less reliable, and generally farming crops is the only real solution to feed a lot of people. But in a land where the farmland was simply too dangerous, would an expansion effort even be able to succeed?
So what is the largest population that a city could actually sustain, in theory, if all of its inhabitants are forced to take shelter behind fortified walls?
Edit: There can still be farmland within the walls, but only within the walls. I can't say what area those walls cover, simply because I'm not sure how much is reasonable. This isn't an Attack on Titan setting where the walls are miles long - the walls are what can reasonably built by settlers within a hundred years, but I doubt if that area is large enough to maintain a sizeable population.