Think filling up your car is expensive? Try doing it one of California's three largest metro areas.

Drivers in Los Angeles, San Francisco and San Diego may have spent as much as $17 billion on gas last year, based on a new estimate from Zendrive, a start-up that analyzes driving behavior to improve commercial driver safety.

And roughly $6.8 billion of that expense was essentially wasted due to bad driving habits and traffic congestion.

The data shows that the approximately 30 million residents of the state's three biggest metropolitan areas spend a lot of money essentially going nowhere.

The total expense estimates were based on data the start-up compiled on the average costs of gas, average fuel ratings of vehicles, average household sizes and average distances for commuting and total miles driven in each metropolitan area during 2017.

The data came from sources including the U.S. Department of Transportation, the U.S. Census, the American Automobile Association, public transit authorities in each region and from GasBuddy, maker of an app that helps consumers find fuel prices, Zendrive CEO Jonathan Matus told CNBC in a phone interview.

The figure for total savings comes from a study by the Department of Energy which found that bad driving habits such as speeding, rapid acceleration and frequent braking cost Americans an extra 40 percent in fuel costs each year.

Zendrive also found that trips during the lunch hour were more dangerous to Bay Area drivers that those made during either the morning or evening commute, while drivers in the region are most aggressive on Mondays.