MADRID — On a recent evening, a hip-looking young woman was sorting through a stack of crates outside a fruit and vegetable store here in the working-class neighborhood of Vallecas as it shut down for the night.

At first glance, she looked as if she might be a store employee. But no. The young woman was looking through the day’s trash for her next meal. Already, she had found a dozen aging potatoes she deemed edible and loaded them onto a luggage cart parked nearby.

“When you don’t have enough money,” she said, declining to give her name, “this is what there is.”

The woman, 33, said that she had once worked at the post office but that her unemployment benefits had run out and she was living now on 400 euros a month, about $520. She was squatting with some friends in a building that still had water and electricity, while collecting “a little of everything” from the garbage after stores closed and the streets were dark and quiet.

Such survival tactics are becoming increasingly commonplace here, with an unemployment rate over 50 percent among young people and more and more households having adults without jobs. So pervasive is the problem of scavenging that one Spanish city has resorted to installing locks on supermarket trash bins as a public health precaution.