Baby boomers have a collective 3.6 million spare rooms around the US, presenting a solution to the millennial housing crisis. Rebecca Cook/Reuters Millennials, the largest generation in US history, are rushing into cities in search of good jobs and opportunities. But many are finding upon their arrival a shortage of affordable housing options.

One solution: Shack up with local older folks.

As people 20 to 36 years old struggle to pay their rent and still come up with disposable income, real-estate company Trulia has found in a recent analysis a surplus of empty rooms in the homes of baby boomers — some 3.6 million rooms, according to Trulia's analysis.

If they decide to live together, this could present lucrative opportunities for both age groups.

"For retired or soon-to-retire boomers, extra rooms are an opportunity to supplement income and offset cost-of-living increases" by an average of $14,000 a year, wrote Trulia data analyst Cameron Simons. "For young adults, renting a room as opposed to a one-bedroom apartment could save them up to $24,000 annually."

Trulia's analysis included data on the top 25 rental markets in the US. The top five markets for would-be landlords included Boston and Cambridge, Massachusetts; Oakland and San Francisco, California; and New York City.

Renting out a room in San Francisco could net boomers an additional $1,800 a month, or $22,000 a year, the analysis found.

Housing experts have been observing the trend of boomer parents becoming empty-nesters for the past several years. Many have predicted there will soon come a "great senior sell-off," in which boomers who feel they have too much space will offload their real estate to millennials.

But the latest research shows millennials just aren't buying. According to Trulia's analysis, boomer homes in the top 25 markets have an average of 4.2 bedrooms but only 2.6 household members.

Not every market carried the potential for so-called "boommates," as Simons called them. In a sample of the 100-largest markets, those in Florida repeatedly fell toward the bottom in the availability of spare rooms. Simons explained the absence of rooms as a product of boomers choosing to downsize after their kids move out.

If younger and older people don't have any qualms with cohabitation, the solution could fill a genuine need for millennials in search of cheaper housing and boomers nearing retirement and facing risks brought on by loneliness and isolation, which happens to be just as deadly as smoking and twice as deadly as obesity.

"Older generations provide a source of wisdom and experience to younger generations," Simons wrote, "and in exchange the older generations are exposed to and taught about new technologies, ideas, and perspectives."