The secret to staying skinny may not be such a secret anymore. A new study looks at why certain fruits and vegetables can help you avoid weight gain over time.

It has to do with the types of natural compounds found in a variety of fruits. And it turns out the compounds found in apples, pears and berries may help your body avoid packing on the pounds.

These fruits are high in flavonoids, compounds already known to be linked to weight loss. In the fight against the scale, you may have heard about the seemingly magical benefits of drinking green tea. At least part of that is thanks to flavonoids.

Before now, there wasn't a whole lot of information on how flavonoids in fruits and vegetables helped your waistline, so researchers decided to find out.

For over two decades, researchers tracked more than 120,000 men and women across the U.S. Every two years participants reported their weight and lifestyle habits. Every four years participants reported their diet.

The study found three subclasses of flavonoids were associated with less weight gain over time. The most consumed foods in those three subclasses included blueberries, strawberries, orange juice, oranges, tea and onions.

The study also noted people in the U.S. are consuming less fruits and vegetables than needed. The authors suggest upping the daily intake of fruit to two cups and vegetables to two-and-a-half cups.

This video includes images from Getty Images, Dani Lurie / CC BY 2.0 and Alan Cleaver / CC BY 2.0.